- substr: documentation ( source)
- strpos: documentation ( source)
- print_r: documentation ( source)
- strtok: documentation ( source)
<?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);