How to echo or print an array in PHP?
To see the contents of array you can use.
1) print_r($array);
or if you want nicely formatted array then:
echo '<pre>'; print_r($array); echo '</pre>';
2) use var_dump($array)
to get more information of the content in the array like datatype and length.
3) you can loop the array using php's foreach();
and get the desired output. more info on foreach in php's documentation website:
http://in3.php.net/manual/en/control-structures.foreach.php
This will do
foreach($results['data'] as $result) {
echo $result['type'], '<br>';
}
If you just want to know the content without a format (e.g. for debuging purpose) I use this:
echo json_encode($anArray);
This will show it as a JSON which is pretty human readable.