3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(get_catering_posts()); function get_catering_posts() { // For each category in the Catering category, fetch their posts return array_map(function ($category) { $category->posts = array_map(function (&$post) use ($category) { // Filter only the custom fields we need to render the page $post->custom_fields = array_filter(get_post_custom($post->ID), function ($item, $item_key) { return in_array($item_key, array( 'price', 'price_portion', 'serving', 'minimum_order', )); }, ARRAY_FILTER_USE_BOTH); return $post; }, get_posts(array( 'category' => $category->cat_ID, ))); return $category; }, get_categories(array( 'child_of' => 16, ))); } function get_posts($array) { return array( 0 => new stdClass, 1 => new stdClass, ); } function get_categories($array) { return array( 0 => new stdClass, 1 => new stdClass, ); } function get_post_custom($id) { return array( 'price' => 'price', 'price_portion' => 'price_portion', 'serving' => 'serving', 'minimum_order' => 'minimum_order', ); }
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined property: stdClass::$cat_ID in /in/jp5f5 on line 15 Warning: {closure}(): Argument #1 ($post) must be passed by reference, value given in /in/jp5f5 on line 8 Warning: Undefined property: stdClass::$ID in /in/jp5f5 on line 10 Warning: {closure}(): Argument #1 ($post) must be passed by reference, value given in /in/jp5f5 on line 8 Warning: Undefined property: stdClass::$ID in /in/jp5f5 on line 10 Warning: Undefined property: stdClass::$cat_ID in /in/jp5f5 on line 15 Warning: {closure}(): Argument #1 ($post) must be passed by reference, value given in /in/jp5f5 on line 8 Warning: Undefined property: stdClass::$ID in /in/jp5f5 on line 10 Warning: {closure}(): Argument #1 ($post) must be passed by reference, value given in /in/jp5f5 on line 8 Warning: Undefined property: stdClass::$ID in /in/jp5f5 on line 10 array(2) { [0]=> object(stdClass)#2 (1) { ["posts"]=> array(2) { [0]=> object(stdClass)#5 (1) { ["custom_fields"]=> array(4) { ["price"]=> string(5) "price" ["price_portion"]=> string(13) "price_portion" ["serving"]=> string(7) "serving" ["minimum_order"]=> string(13) "minimum_order" } } [1]=> object(stdClass)#6 (1) { ["custom_fields"]=> array(4) { ["price"]=> string(5) "price" ["price_portion"]=> string(13) "price_portion" ["serving"]=> string(7) "serving" ["minimum_order"]=> string(13) "minimum_order" } } } } [1]=> object(stdClass)#3 (1) { ["posts"]=> array(2) { [0]=> object(stdClass)#7 (1) { ["custom_fields"]=> array(4) { ["price"]=> string(5) "price" ["price_portion"]=> string(13) "price_portion" ["serving"]=> string(7) "serving" ["minimum_order"]=> string(13) "minimum_order" } } [1]=> object(stdClass)#8 (1) { ["custom_fields"]=> array(4) { ["price"]=> string(5) "price" ["price_portion"]=> string(13) "price_portion" ["serving"]=> string(7) "serving" ["minimum_order"]=> string(13) "minimum_order" } } } } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
34.84 ms | 409 KiB | 8 Q