rotten69 Posted May 12, 2011 Share Posted May 12, 2011 Hey all, I'm just having a problem with this code.. the local server says it has an error on a particular line that will be pointed out in the coding section. <?php $hd = fopen('content.txt', 'r'); $line = fgets($hd); $content = array(); while($line) { $word = explode(',', $line); $content [$word[0]] => array('img_path' => $word[1], 'description' => $word[2], 'price' => $word[3]); // the error message is indicating this line is broken!! Is it because of an equal sign missing? I tried putting an equal sign, but still it doesn't run. $line = fgets($hd); } fclose($hd); ?> Your help is greatly needed.. Quote Link to comment https://forums.phpfreaks.com/topic/236172-opening-a-file-in-php/ Share on other sites More sharing options...
kenrbnsn Posted May 12, 2011 Share Posted May 12, 2011 This line <?php $content [$word[0]] => array('img_path' => $word[1], 'description' => $word[2], 'price' => $word[3]); ?> is where the error is. You probably want <?php $content[$word[0]] = array('img_path' => $word[1], 'description' => $word[2], 'price' => $word[3]); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/236172-opening-a-file-in-php/#findComment-1214261 Share on other sites More sharing options...
rotten69 Posted May 12, 2011 Author Share Posted May 12, 2011 Thanks, ken. This solved the problem I had. I tried "=" instead of "=>", then it did not work for me at all. Just a quick question. I'm interested in programming in PHP, but I still struggle with the logic of it. What do you think it could help me learn it and master it eventually? Quote Link to comment https://forums.phpfreaks.com/topic/236172-opening-a-file-in-php/#findComment-1214312 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.