3v4l.org

run code in 200+ 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 - 7.3.0rc4
Array ( [test 1] => Array ( [0] => 123 [1] => 456 ) [test 2] => Array ( [0] => 789 [1] => 0 ) )