What is the best way to output a multidimensional array in PHP?

When outputting a multidimensional array in PHP, the best way is to use a combination of loops and built-in functions like print_r() or var_dump(). These functions allow you to easily display the contents of the array in a structured format, making it easier to understand the data hierarchy.

// Sample multidimensional array
$multiArray = array(
    array("John", "Doe", 30),
    array("Jane", "Smith", 25),
    array("Tom", "Jones", 40)
);

// Output the multidimensional array using print_r()
echo "<pre>";
print_r($multiArray);
echo "</pre>";