3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $dashAccess = "1-10:rw,14:rw|10-10:ro,14:ro"; $outArray = []; foreach (explode('|', $dashAccess) as $bigPiece) { list($medKey, $medPiece) = explode('-', $bigPiece); $outArray[$medKey] = []; foreach (explode(',', $medPiece) as $smallPiece) { list($crumbleKey, $crumblePiece) = explode(':', $smallPiece); $outArray[$medKey][$crumbleKey] = $crumblePiece; } } var_dump($outArray);
Output for 5.4.0 - 7.1.0
array(2) { [1]=> array(2) { [10]=> string(2) "rw" [14]=> string(2) "rw" } [10]=> array(2) { [10]=> string(2) "ro" [14]=> string(2) "ro" } }
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/mOdb8 on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/mOdb8 on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/mOdb8 on line 4
Process exited with code 255.