hello, i'm having a problem reading a text file and converting it to an array.
The text file looks like this:
red=60.00
blue=60.00
green=60.00
and my code looks like this:
<?php
$filename = 'details.txt';
$fp = fopen($filename, "r");
$contents = fread($fp, filesize($filename));
fclose($fp);
$temp_array = split('\n',$contents);
foreach ($temp_array as $entry)
{
//echo "blar";
list($name,$value) = split('=',$entry);
$pricing_array[$name] = $value;
}
echo "<br>";
echo $pricing_array['blue'];
?>
I figure $contents is a string so first i split it at the new line character "\n" then i can split it at the = sign. but it doesnt seem to be working as $pricing_array['blue'] doesnt output anything.
Thanks in advance
-emrys