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($s, 0, $p); $s2 = substr($s, $p); if(empty($parentId)){ $parents[$s] = $id; }else{ $parentId = $parents[$s]; } $nodes[] = array($s1, $id, $parentId); $id += 1; if(isset($s2)){ fillCategory($s2, $id, $parentId); } } fillCategory('Мужчинам / Носки / Белые', 0, null); var_dump($nodes);
based on PUFgs
Output for 7.2.0
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 262144 bytes) in /in/O5gGe on line 6
Process exited with code 255.
Output for 7.1.10

Process exited with code 137.
Output for 7.1.0 - 7.1.7
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 20480 bytes) in /in/O5gGe on line 14
Process exited with code 255.
Output for 7.0.20
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 262144 bytes) in /in/O5gGe on line 15
Process exited with code 255.
Output for 7.0.0 - 7.0.6
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 4096 bytes) in /in/O5gGe on line 8
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 64 bytes) in /in/O5gGe on line 10
Process exited with code 255.
Output for 5.5.24 - 5.5.35
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 72 bytes) in /in/O5gGe on line 14
Process exited with code 255.
Output for 5.4.10 - 5.4.45
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 130968 bytes) in /in/O5gGe on line 17
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 71 bytes) in /in/O5gGe on line 14
Process exited with code 255.