1<?php
2$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
3echo "<pre>";
4print_r ($a);
5echo "</pre>";
6?>
7
8Output:
9
10Array
11(
12 [a] => apple
13 [b] => banana
14 [c] => Array
15 (
16 [0] => x
17 [1] => y
18 [2] => z
19 )
20)
21
1function echo_arr($arr){
2 for ($i=0; $i < count($arr); $i++) {
3 echo $arr[$i];
4 }
5 }
6
7echo_arr($your_array_here);
1// raw array output
2print_r($arr);
3
4// the above well-formatted
5echo '<pre>'; print_r($array); echo '</pre>';
6
7// more details like datatype and length
8var_dump($arr);
9
10// output that PHP understands
11var_export($arr);
12
13// by foreach loop
14foreach($arr as $key=>$value)
15 echo $key, '=>', $value; // $value must be convertible to string
1<?php
2$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
3print_r ($a);
4?>