WEB TUTORIALS
PRACTICE EXAMPLES
HTML REFERENCES
CSS REFERENCES
PHP REFERENCES
Advertisements

How to display array structure and values in PHP

Topic: PHP / MySQLPrev|Next

Answer: Use the PHP print_r() or var_dump() Statement

You can either use the PHP print_r() or var_dump() statement to see or check the structure and values of an array in human-readable format on the screen. The var_dump() statement however gives more information than print_r(). Let's see how it basically works:

<?php
$cities = array("London", "Paris", "New York");
 
// Print the cities array
Print_r($cities);
echo "<hr>";
var_dump($cities);
?>

Related FAQ

Here are some more FAQ related to this topic:

Advertisements
Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties