{"id":3176,"date":"2012-05-07T10:33:15","date_gmt":"2012-05-07T10:33:15","guid":{"rendered":"http:\/\/phpcodez.com\/?p=3176"},"modified":"2012-05-07T10:33:15","modified_gmt":"2012-05-07T10:33:15","slug":"array_reduce","status":"publish","type":"post","link":"http:\/\/phpcodez.com\/array_reduce\/","title":{"rendered":"array_reduce"},"content":{"rendered":"<div>It reduce the array to a single value using a callback function<\/p>\n<p><strong>Example<\/strong><\/p>\n<p>&lt;?php<br \/>\nfunction reduce($arg1, $arg2){<br \/>\n$arg1 += $arg2;<br \/>\nreturn $arg1;<br \/>\n}<\/p>\n<p>$array1 = array(1, 7, 8, 4, 5);<br \/>\n$array2 = array_reduce($array1, &#8220;reduce&#8221;);<br \/>\nprint_r($array2);<br \/>\n?&gt;<\/p>\n<p><strong>Output<\/strong><\/p>\n<p>25<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>It reduce the array to a single value using a callback function Example &lt;?php function reduce($arg1, $arg2){ $arg1 += $arg2; return $arg1; } $array1 = array(1, 7, 8, 4, 5); $array2 = array_reduce($array1, &#8220;reduce&#8221;); print_r($array2); ?&gt; Output 25<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[54,213,370],"class_list":["post-3176","post","type-post","status-publish","format-standard","hentry","category-php","tag-array","tag-functions","tag-php"],"_links":{"self":[{"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/posts\/3176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/comments?post=3176"}],"version-history":[{"count":0,"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/posts\/3176\/revisions"}],"wp:attachment":[{"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/media?parent=3176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/categories?post=3176"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/tags?post=3176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}