Forum Moderators: coopster

Message Too Old, No Replies

Arrays Not Working

Arrays not working

         

webmongrel

10:03 am on Apr 21, 2005 (gmt 0)

10+ Year Member



Hi, im having a problem with a array in one of my scripts, any help would be appreciated.

<?php
$colors = array('red', 'blue', 'green', 'yellow');

foreach ($colors as $color) {
echo "$color";
}

?>

And all this produces is ArrayArrayArrayArray

What am i doing wrong?

Thanks

IamStang

11:26 am on Apr 21, 2005 (gmt 0)

10+ Year Member



There are numerous things you can do with arrays. It might help others answer your question if you described what you are trying to accomplish with your array.

SoulAssassin

11:45 am on Apr 21, 2005 (gmt 0)

10+ Year Member



I copied your code exactly and i got

redbluegreenyellow

as i expected to.

Don't know if it will make any difference at your end but personally i wouldn't have quotes around the variable $color where you are echoing it out.

So...

<?php

$colors = array('red', 'blue', 'green', 'yellow');

foreach ($colors as $color)
{
echo $color;
}

?>

webmongrel

9:15 pm on Apr 21, 2005 (gmt 0)

10+ Year Member



Thanks for your replies, it appears it was a problem with zend needing updating