Problems with PHP4 & arrays

From: Date: Tue, 06 Jun 2000 13:09:27 +0000
Subject: Problems with PHP4 & arrays
Groups: php.general 
Request: Send a blank email to php-general+get-1127@lists.php.net to get a copy of this message
I have written this little Script: <? $TIT[0]=5; $TIT[1]=3; $TIT[2]=6; $TIT[4]=9; $TIT[7]=2; for ($i=0; $i<sizeof($TIT); $i++) { echo $i." - ".$TIT[$i]."<br>\n"; } ?> if I run it, the output is: 0 - 5<br> 1 - 3<br> 2 - 6<br> 3 - <br> 4 - 9<br> But i'd like to have something like this: 0 - 5<br> 1 - 3<br> 2 - 6<br> 3 - <br> 4 - 9<br> 5 - <br> 6 - <br> 7 - 2<br> Why the program doesn't output all values (from 0 to 7)? Why it doesn't set all not defined values to "". I don't knw how many values need before running the script, I'd like that the array have all values defined before the last not null (in this case $TIT[7]), in Perl the problem there isn't, in PHP yes. Please help me Thanks Andrea Busia

« previous php.general (#1127) next »