{"id":3328,"date":"2014-03-23T02:20:44","date_gmt":"2014-03-23T02:20:44","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/23\/php-anonymous-function-with-array_walk-collection-of-common-programming-errors-2\/"},"modified":"2014-03-23T02:20:44","modified_gmt":"2014-03-23T02:20:44","slug":"php-anonymous-function-with-array_walk-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/23\/php-anonymous-function-with-array_walk-collection-of-common-programming-errors-2\/","title":{"rendered":"PHP Anonymous function with array_walk-Collection of common programming errors"},"content":{"rendered":"<p>Yes, true anonymous functions (closures) are only available from PHP 5.3, however you can still create an anonymous function in earlier versions of PHP using the create_function() call, which can be used with array_walk(). Something like:<\/p>\n<pre><code>array_walk($myArray, create_function('&amp;$value,$key', '$value = \\'\"\\'.$value.\\'\"\\';'));\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Yes, true anonymous functions (closures) are only available from PHP 5.3, however you can still create an anonymous function in earlier versions of PHP using the create_function() call, which can be used with array_walk(). Something like: array_walk($myArray, create_function(&#8216;&amp;$value,$key&#8217;, &#8216;$value = \\'&#8221;\\&#8217;.$value.\\'&#8221;\\&#8217;;&#8217;));<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3328","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3328","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3328"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3328\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}