Re: help, array values echoed as Array on loop!
| From: | Richard Lynch | Date: | Fri, 06 Sep 2002 00:52:10 +0000 |
| Subject: | Re: help, array values echoed as Array on loop! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-115379@lists.php.net to get a copy of this message | ||
>$ID_arr[] = explode(',', $pictures); # make db data into array
>
>This is the string:
>
>15,16,17,18,19
>
>why does it echo as Array?
Because you have a "two-dimensional" array:
ID_arr = array(
array(15, 16, 17, 18, 19)
);
The reason you have a 2-D array is that you have [] in the assignment:
$ID_arr[] = <<<< function that builds an array >>>>>>>;
So the right-hand-side of = turns into an Array, and *then* you use [] to
force ID_arr to be an Array, and you stuff the one Array into the first open
position in the ID_arr Array.
Get rid of the [] and everything will be beautiful.
Any time you try to print something and get Array, it's because whatever you
have done has caused that thing to be an Array itself. If you didn't want
it to be an Array, figure out where/how you got an "extra" layer of
Array-ness in your code.
--
Like Music? http://l-i-e.com/artists.htm