3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $nodes = array(); $parents = array(); function fillCategory($s, $id, $parentId){ $p = strpos('/', $s); $s1 = substr(0, $p); $s2 = substr($p); if(empty($parentId)){ $parents[$s] = $id; }else{ $parentId = $parents[$s]; } $nodes[] = array($s, $id, $parentId); $id += 1; if(isset($s2)){ fillCategory($s, $id, $parentId); } } fillCategory('Мужчинам / Носки / Белые'); var_dump($nodes);
based on Efdsq
Output for 7.1.0 - 7.2.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function fillCategory(), 1 passed in /in/f2H9N on line 21 and exactly 3 expected in /in/f2H9N:5 Stack trace: #0 /in/f2H9N(21): fillCategory('\xD0\x9C\xD1\x83\xD0\xB6\xD1\x87\xD0\xB8\xD0\xBD\xD0\xB0\xD0...') #1 {main} thrown in /in/f2H9N on line 5
Process exited with code 255.
Output for 5.3.20 - 7.0.20
Warning: Missing argument 2 for fillCategory(), called in /in/f2H9N on line 21 and defined in /in/f2H9N on line 5 Warning: Missing argument 3 for fillCategory(), called in /in/f2H9N on line 21 and defined in /in/f2H9N on line 5 Warning: substr() expects at least 2 parameters, 1 given in /in/f2H9N on line 8 Notice: Undefined variable: id in /in/f2H9N on line 10 Notice: Undefined variable: id in /in/f2H9N on line 14 Notice: Undefined variable: parentId in /in/f2H9N on line 14 Notice: Undefined variable: id in /in/f2H9N on line 15 array(0) { }