Hello everyone,
This past weekend has been decent when it comes to me learning PHP. However, I’m having a problem that I can’t figure out. For some reason, it appears that an array I have isn’t incrementing.
The array contains elements pulled in by a variable in a loop - I’m guessing that’s where the problem is, except that I AM getting the elements, but no incrementing. Here’s the code I’ve got with some notations:
[php]
<?php if ($handle = opendir('./event-titles')) { while (false !== ($fileName = readdir($handle))) { if ($fileName != "." && $fileName != "..") { $fileContent = $fileName; $openedFile=fopen("event-titles/".$fileContent,"r"); while(!feof($openedFile)) { $fileContent = fgets($openedFile); } $eventStuff = array($fileContent); foreach ($eventStuff as $key => $val) { echo $eventStuff."";//Returns "Array". echo $key."
";//Returns "0" (zero), does not increment. echo $val."
";//Correctly returns each element in array. } fclose($openedFile); } } closedir($handle); } ?>
[/php]
I’ve gone through PHP.net and a bunch of other sites, but this one’s got me confused. It appears that I’m getting values into the array, since they’re being echoed out successfully, but I’m not sure what’s keeping the array from incrementing. (I need to increment so I can sort - I think.)
Dave