3v4l.org

run code in 300+ PHP versions simultaneously
<?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);
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
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.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 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) { }

preferences:
155.35 ms | 403 KiB | 200 Q