RE: [PHP] help, array values echoed as Array on loop!
| From: | victor | Date: | Mon, 02 Sep 2002 19:46:22 +0000 |
| Subject: | RE: [PHP] help, array values echoed as Array on loop! | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-21521@lists.php.net to get a copy of this message | ||
Ok, if I change $ID_arr[] to $ID_arr I think it gives me what I want.
- Victor > www.argilent.com
-----Original Message-----
From: Victor [mailto:victor@argilent.com]
Sent: Monday, September 02, 2002 3:39 PM
To: 'PHP'
Subject: [PHP] help, array values echoed as Array on loop!
I have tried both ways to loop through an array and output the data and
verify that the array is an array and I get no erros but I get this
value, which should not be so.
Here I'm checking if it's an array:
if (!is_array($ID_arr)) { # show error if no array
echo '$ID_arr is not an array.';
}
here I'm counting the keys but it only outputs as 1:
$key = count($ID_arr);
echo $key;
here are two loops that do the same thing and they both output Array:
for($i = 0; $i < count($ID_arr); $i++) {
echo $ID_arr[$i];
}
foreach($ID_arr as $ind_picture) {
echo $ind_picture;
}
Why? If it helps, in order to get the array, the values were taken from
a database and exploded from a coma delimited string.
$ID_arr[] = explode(',', $pictures); # make db data into array
This is the string:
15,16,17,18,19
I want each array element to contain
=> 15
=> 16
=> 17
etc...
why does it echo as Array?
- Victor > www.argilent.com
______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca