I have some data I'm trying to parse into an array.
It looks something like this:
302 jkahfvaznvhhdffbvhsfbhfbvfvzdfbv
303 jnzgfdvbldbfvjbdfjafbvlafvl
304 zklnfvjkvzvfzhvkzfvkjhzvahvjkzfvj
I need to fill an array names $ar_lines where the keys are 302, 303, and 304 with the values being assigned accordingly.
$lines = file($myfile);
foreach($lines as $line_num => $line)
{
// need to skip the first line
if($line_num > 0) {
$firstsp = strpos($line, ' ');
// here's where I run into trouble
$ar_lines[] = trim(substr($line, 0, $firstsp)), trim(substr($line, $firstsp+1)));
}
}
print_r($ar_lines);
echo "<br>";
I can't figure this one out. explode() with a space doesn't set the keys, it makes the
values I want to be keys array members.