0
how do we print the whole elements in an array?
7 Antworten
+ 2
Then just use a foreach loop:
foreach($arr as $key => $value)
{
echo $value . ' ';
}
+ 1
you can use print_r() function to print the whole array.
<?php
$arr = array(1, 2, 3);
print_r($arr);
?>
0
But it gives me "Array ( [0] => 1[1] => 2[2] => 3 )" as the output.I juz wanna print the contents only, without the indeces.
0
yeah.!! I got it..Thank you :-)
0
Don't use print_r() method. It will only print the storing format and not the individual values of the indexes. Use echo instead
0
u got to echo the the variable you specify for the array
0
use foreach loop
<?php
$arr=array("John","James","Peter");
foreach($arr as $value) {
echo $value."<br>";
}
?>