It all depends on what you want to do. print_r()
and var_dump()
are convenient, but typically only used for debugging. While the code you posted is convenient for showing how those array functions work, I personally almost never use them. Either I'm using foreach()
to loop through the whole array, or even just doing an implode()
if I just want to output all the values, e.g. (untested):
$array = array("current","next","reset","prev","end");
echo "<p>The array values are:</p>\n<ul>\n<li>";
echo implode("</li>\n<li>", $array);
echo "</li>\n</ul>\n";
But again...it all depends on the actual functional requirement; there's no one catch-all method that you'll always use.