it' s correct to show the array with echo, with print_ r and var_dump is showing all the array

$array = array("current","next","reset","prev","end");
$mode = current($array);
echo "current = ".$mode;
echo "<br/><br/>";
$mode1 = next($array);
echo "next = ".$mode1;
echo "<br/><br/>";
$mode2 = reset($array);
echo "reset = ".$mode2;
echo "<br/><br/>";
$mode4 = next($array);
$mode4 = next($array);
$mode4 = next($array);
$mode4 = prev($array);
echo "prev = ".$mode4;
echo "<br/><br/>";
$mode5 = end($array);
echo "end =".$mode5;

    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.

    Write a Reply...