PHP Array Function

  • Hi guys, in this tutorial we will learn PHP Array function.
  • There are many functions for sorting array ! It sorts array in both ascending and descending order .
  • sort()
  • ksort()
  • asort()
  • arsort()
  • krsort()

PHP Example

Edit it yourself

<!DOCTYPE html>
<html>
<body>

<?php
  $arr = array("one","two","three");
  sort($arr); //using sort function
  print_r($arr);
  echo "<br>";
  asort($arr); //using asort function
  print_r($arr);
  echo "<br>";
  ksort($arr);//using ksort function
  print_r($arr);
  echo "<br>";
  arsort($arr);//using arsort function
  print_r($arr);
  echo "<br>";
  krsort($arr);//using krsort function
  print_r($arr);
  echo "<br>";
?>


</body>
</html>

Output of PHP comment

Edit it yourself
  • Previous
  • Next