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__($array,$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() ))))));
Output for 5.4.0 - 5.4.15
Parse error: syntax error, unexpected ''categoryTitle'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in /in/sPQ2l on line 17
Process exited with code 255.
Output for 5.3.0 - 5.3.25
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /in/sPQ2l on line 17
Process exited with code 255.