Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Associative Arrays in PHP

<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>

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.