3v4l.org

run code in 500+ PHP versions simultaneously
<?php $classType = [ ["class" => "1", "type" => "A"], ["class" => "2", "type" => "A"], ["class" => "3", "type" => "B"] ]; $clollege['studentDetails'] = [ ["grade" => "2", "hobbies" => ["A" , "B"] ], ["grade" => "2", "hobbies" => ["A" ] ], ["grade" => "3", "hobbies" => [ "C" ] ] ]; foreach($clollege['studentDetails'] as $key => &$val){ $grade = $val['grade']; $val['type'] = array_reduce($classType, function($r, $item) use ($grade){ return ($item['class'] == $grade) ? $item['type'] : $r; }); } print_r($clollege);
TypeError: array_map(): Argument #1 ($callback) must be a valid callback or null, class Basic_Database does not have a method "escapeColumn" in /htdocs/index.php:45 Stack trace: #0 /htdocs/index.php(45): array_map() #1 /library/PhpShell/Input.php(135): Basic_Entity->save() #2 /library/PhpShell/Input.php(332): PhpShell_Input->_updateFunctionCalls() #3 /cache/Templates/script/vld:html.php(1): PhpShell_Input->getVld() #4 /htdocs/index.php(53): include('...') #5 /cache/Templates/script:html.php(1): Basic_Template->show() #6 /htdocs/index.php(53): include('...') #7 /htdocs/index.php(28): Basic_Template->show() #8 /library/PhpShell/Action/Script.php(122): Basic_Action->showTemplate() #9 /htdocs/index.php(30): PhpShell_Action_Script->run() #10 /htdocs/index.php(50): Basic_Controller->run() #11 /htdocs/index.php(50): Basic::_dispatch() #12 /htdocs/index.php(56): Basic::bootstrap() #13 {main}