php echo an array code example
Example 1: php echo arry
echo json_encode($anArray);
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: php echo array
foreach($results as $result) {
echo $result . '<br>';
}
Example 6: php echo array
<?php
$cars = array("Volvo", "BMW", "Toyota");
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
?>