3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function searchNested($arr,$keyword){ $found = array(); foreach($arr as $item){ if($item['categorySlug']==$keyword){ $found[] = $item; }else{ $found = array_merge($found,__FUNC__($item['categoryNested'],$keyword)); } } return $found; } var_dump(searchNested(array(array ( 'categoryName' => 'Moto', 'categoryTitle' => 'Moto', 'categorySlug' => 'moto-and-tech', 'categoryAttr' => array ( 0 => 'test1', 1 => 'test2', 2 => 'test3', 3 => 'test4' ), 'categoryNested' => array ( 0 => array ( 'categoryName' => 'anything', 'categoryTitle' => 'anything', 'categorySlug' => 'anything', 'categoryAttr' => array ( 0 => 'test1', 1 => 'test1', 2 => 'test1', 3 => 'test1' ), 'categoryNested' => array() ), 1 => array ( 'categoryName' => 'any', 'categoryTitle' => 'any', 'categorySlug' => 'any', 'categoryAttr' => array ( 0 => 'test1', 1 => 'test1', 2 => 'test1', 3 => 'test1' ), 'categoryNested' => array() )))),'any'));
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function __FUNC__() in /in/MXRfh:8 Stack trace: #0 /in/MXRfh(55): searchNested(Array, 'any') #1 {main} thrown in /in/MXRfh on line 8
Process exited with code 255.
Output for 5.0.0 - 5.6.28, hhvm-3.10.0 - 3.12.0
Fatal error: Call to undefined function __FUNC__() in /in/MXRfh on line 8
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: __func__() in /in/MXRfh on line 8
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: __func__() in /in/MXRfh on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: __func__() in /in/MXRfh on line 8