[Techtalk] foreach won't but for will
Emma Jane Hogbin
emmajane at xtrinsic.com
Mon Feb 17 16:19:16 EST 2003
I switched the foreach statement to a for($i=0; $i < sizeof($array); $i++)
and now that part works. I don't really understand why the foreach
wouldn't work...I was pretty sure that foreach was supposed to work on all
arrays, but maybe it's only associative arrays?
I think I may have found it in the PHP documentation.... (go figure):
/* foreach example 2: value (with key printed for illustration) */
$a = array (1, 2, 3, 17);
$i = 0; /* for illustrative purposes only */
foreach($a as $v) {
print "\$a[$i] => $v.\n";
$i++;
}
Looks like you have to count if it's not an associative array. Bleh. Next
problem -- to fix the in_array that says it's not.
emma
--
Emma Jane Hogbin
[[ 416 417 2868 ][ www.xtrinsic.com ]]
More information about the Techtalk
mailing list