sort an associative array on the basis of keys : Array sort : Data Structure PHP Source Code


PHP Source Code » Data Structure » Array sort »

 

sort an associative array on the basis of keys



<?php
  $nameandage = array (
                      D => 24,
                      A => 44,
                      C => 34,
                      E => 55,
                      B => 21,
                      F => 48);
  ksort ($nameandage);
 
  foreach ($nameandage as $keys => $val) {
    echo "$keys = $val""n";
  }
?>

           
       



HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo Data Structure
» Array sort