Printing Just the data from an Array

I have an array that currently prints out like this:

[php]
Array
(
[0] => Array
(
[date] => Sunday October 7, 2012
[status] => Final
[redfruit] => apple
[redscore] => 17
[greenfruit] => bananna
[homescore] => 23
[winner] => bananna
)

[1] => Array
    (
        [date] => Sunday October 7, 2012
        [status] => Final
        [redfruit] => peach
        [redscore] => 12
        [greenfruit] => Kiwi
        [homescore] => 9
        [winner] => peach
    )

[2] => Array
    (
        [date] => Sunday October 8, 2012
        [status] => Final
        [redfruit] => appricot
        [redscore] => 28
        [greenfruit] => grape
        [homescore] => 22
        [winner] => appricot
    )

[3] => Array
    (
        [date] => Sunday October 8, 2012
        [status] => Final
        [redfruit] => grapefruit
        [redscore] => 6
        [greenfruit] => watermellon
        [homescore] => 4
        [winner] => grapefruit
    )

[/php]

I will need a output for a marquee that prints out like this:
[php]
Sunday October 7, 2012… apple 17, bananna, 23 Final… peach, 12 kiwi, 9 Final… Sunday October 8, 2012…appricot, 28 grape 22 Final… grapefruit, 6 watermellon, 4 Final…[/php]

I am a PHP newbie and non of my book seem to cover this. Please help.

Mike

You will need to substitute your array name for $array in the following code, but this should get you started:[php]$old_date = ‘’;
foreach($array as $result)
{
$date = $result[‘date’];
if($date != $old_date) echo $date.’… ';
$old_date = $date;
echo "$result[redfruit], $result[redscore] $result[greenfruit], $result[homescore] $result[status]… ";
}[/php]

Thank you very much! That worked perfect.

My pleasure, let us know if you run into any other issues.

jay

Sponsor our Newsletter | Privacy Policy | Terms of Service