Welcome Guest, Not a member yet? Register   Sign In
echo array values?
#1

[eluser]Josssi[/eluser]
Hi Smile,

could you advice me some trick how to print all value in once with echo please? I need something like:

Code:
$colors = array(
             'red' => 'RED',
             'blue' => 'BLUE',
             'green' => 'GREEN',
          );

echo 'My all colors are:'.$colors;

I want just know how to correct write array in echo, to print all values of array in one row.
#2

[eluser]JoostV[/eluser]
Code:
implode(', ' ,  $colors);
#3

[eluser]cbwd[/eluser]
Or if it's just for debugging, print_r($array)
#4

[eluser]solid9[/eluser]
I tried joostV

That's cool, here is the complete codes.
Code:
$colors = array(
     'red' => 'RED',
     'blue' => 'BLUE',
     'green' => 'GREEN',
);
    
echo implode(', ' ,  $colors);

#5

[eluser]Josssi[/eluser]
supreme, thanks for advice Wink
#6

[eluser]JoostV[/eluser]
Wink
#7

[eluser]CodeIgniteMe[/eluser]
[quote author="cbwd" date="1332804028"]Or if it's just for debugging, print_r($array)[/quote]

or you could also use
Code:
var_dump($array);
#8

[eluser]Josssi[/eluser]
no no,print_r i know, i needet print it like echo Wink, this first advice helped me Wink
#9

[eluser]InsiteFX[/eluser]
PHP Manual Print

Code:
<?php

$line = array( 'title' => "Hello", 'date' => 'Today');

echo <<<EOT
    Title: {$line['title']}
    Date: {$line['date']}
EOT;

?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB