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 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
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" } } } } }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
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 15 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 15 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 15 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 15 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" } } } } }
Output for 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined property: stdClass::$cat_ID in /in/jp5f5 on line 15 Notice: Undefined property: stdClass::$ID in /in/jp5f5 on line 10 Notice: Undefined property: stdClass::$ID in /in/jp5f5 on line 10 Notice: Undefined property: stdClass::$cat_ID in /in/jp5f5 on line 15 Notice: Undefined property: stdClass::$ID in /in/jp5f5 on line 10 Notice: 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" } } } } }
Output for 7.3.32 - 7.3.33
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" } } } } }
Output for 5.5.24 - 5.5.35
Notice: Undefined property: stdClass::$cat_ID in /in/jp5f5 on line 15 Notice: Undefined property: stdClass::$ID in /in/jp5f5 on line 10 Notice: Use of undefined constant ARRAY_FILTER_USE_BOTH - assumed 'ARRAY_FILTER_USE_BOTH' in /in/jp5f5 on line 12 Warning: array_filter() expects at most 2 parameters, 3 given in /in/jp5f5 on line 12 Notice: Undefined property: stdClass::$ID in /in/jp5f5 on line 10 Notice: Use of undefined constant ARRAY_FILTER_USE_BOTH - assumed 'ARRAY_FILTER_USE_BOTH' in /in/jp5f5 on line 12 Warning: array_filter() expects at most 2 parameters, 3 given in /in/jp5f5 on line 12 Notice: Undefined property: stdClass::$cat_ID in /in/jp5f5 on line 15 Notice: Undefined property: stdClass::$ID in /in/jp5f5 on line 10 Notice: Use of undefined constant ARRAY_FILTER_USE_BOTH - assumed 'ARRAY_FILTER_USE_BOTH' in /in/jp5f5 on line 12 Warning: array_filter() expects at most 2 parameters, 3 given in /in/jp5f5 on line 12 Notice: Undefined property: stdClass::$ID in /in/jp5f5 on line 10 Notice: Use of undefined constant ARRAY_FILTER_USE_BOTH - assumed 'ARRAY_FILTER_USE_BOTH' in /in/jp5f5 on line 12 Warning: array_filter() expects at most 2 parameters, 3 given in /in/jp5f5 on line 12 array(2) { [0]=> object(stdClass)#2 (1) { ["posts"]=> array(2) { [0]=> object(stdClass)#5 (1) { ["custom_fields"]=> NULL } [1]=> object(stdClass)#6 (1) { ["custom_fields"]=> NULL } } } [1]=> object(stdClass)#3 (1) { ["posts"]=> array(2) { [0]=> object(stdClass)#7 (1) { ["custom_fields"]=> NULL } [1]=> object(stdClass)#8 (1) { ["custom_fields"]=> NULL } } } }

preferences:
209.85 ms | 405 KiB | 198 Q