3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $temp="test 1-123.456\ntest 2-789.0\n"; $tok=strtok($temp,"\n"); while ($tok !== false) { $pos=strpos($tok,'-'); $pos2=strpos($tok,'.',$pos); $temp2=substr($tok,0,$pos); $pos++; $wordlist[$temp2]=array((int)substr($tok,$pos,$pos2-$pos),(int)substr($tok,$pos2+1)); $tok=strtok("\n"); } print_r($wordlist);
Output for 4.3.0 - 5.6.25, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [test 1] => Array ( [0] => 123 [1] => 456 ) [test 2] => Array ( [0] => 789 [1] => 0 ) )