<html> <body> <?php /* Create an Associate Array */ $clientInfo = array("name" => "Vinay Gulati", "city" => "Toronto", "country" => "Canada"); /* Print an Array */ print "Original Array is: "; print_r($clientInfo); /* Reverse an array using PHP funciton */ print "<br />Reversed Array is: "; print_r(array_reverse($clientInfo)); /* Reverse an array without using PHP function */ print "<br />Reversed Array without using any inbuilt PHP function is: "; $tmp_Array=$clientInfo; $index=array(); unset($clientInfo); $i=0; foreach ($tmp_Array as $key => $value) { $index[$i]=$key; $i++; } for($i; $i>0;$i--) { $clientInfo[$index[$i-1]]=$tmp_Array[$index[$i-1]]; } print_r($clientInfo); ?> </body> </html>
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more