print array php code example
Example 1: print array php
<?php
$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
echo "<pre>";
print_r ($a);
echo "</pre>";
?>
Output:
Array
(
[a] => apple
[b] => banana
[c] => Array
(
[0] => x
[1] => y
[2] => z
)
)
Example 2: php print array
print_r($arr);
echo '<pre>'; print_r($array); echo '</pre>';
var_dump($arr);
var_export($arr);
foreach($arr as $key=>$value)
echo $key, '=>', $value;
Example 3: php echo array
<?php
$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
print_r ($a);
?>
Example 4: php echo array
$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
print_r ($a);
Example 5: dsiplay array on php
$array = array(
1 => 'apple',
2 => 'banana',
)
echo "<pre>";
print_r($array);
echo "</pre>";
echo "<pre>";
var_dump($array);
echo "</pre>";
pr ($array);
Example 6: print array in php
print_r($array);