ksort() - Sort array in ascending order, according to key


SUBMITTED BY: henry1874w

DATE: June 17, 2017, 1:15 p.m.

FORMAT: Text only

SIZE: 239 Bytes

HITS: 220

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <?php
  5. $age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
  6. ksort($age);
  7. foreach($age as $x => $x_value) {
  8. echo "Key=" . $x . ", Value=" . $x_value;
  9. echo "<br>";
  10. }
  11. ?>
  12. </body>
  13. </html>

comments powered by Disqus