|
-
Sep 7th, 2004, 07:14 AM
#2
I've never heard that it's valid to compare an integer to an array, neither is there any indication in the PHP docs that it is so. This is not perl, after all.
Even if it were, even if it yielded the number of elements in the array, using <= would be invalid and would attempt to access one element past the end.
Furthermore, because array entries can have string indices, you're not even guaranteed to get anything by looping a numeric index.
There are only two reliable ways of looping over complete arrays, and those are foreach and while(each) loops. There's no reason not to use them either.
Code:
foreach($result_array as $subarray) {
echo " <tr>\n";
foreach ($subarray as $data){
echo " <td>$data</td>\n";
}
echo " </tr>\n";
}
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|