array sort function - sort the given array regular order by values
array-sort-function-example-in-php.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>array sort function - sort the given array regular order by values</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Md Iqbal Hosan">
<meta name="title" content="array sort function - sort the given array regular order by values">
<meta name="keywords" content="php, example, code, array, function, sort">
<meta name="description" content="array sort function - sort the given array regular order by values">
<style>
h2, h3, h4{background:#eee; color:#000079;}
h2{ padding:3px; margin:3px; font-size:23px;}
h3{ padding:2px; margin:2px; font-size:19px;}
h4{ padding:2px; margin:2px; font-size:18px;}
body{ background:#FFFFFa;}
</style>
</head>
<body>
<h2>array sort function - sort the given array regular order by values</h2>
<pre>
<?php
/*
----------------------------------------------------
let's make an array and fill it up with some values
----------------------------------------------------
*/
$myArray = array("apple","zoo","cow","book","modon");
echo "<h4>Output of myArray</h4>";
print_r($myArray);
/*
--------------------------------------------------------------------------------
we want to sort the array regular order by values by using array sort function
--------------------------------------------------------------------------------
*/
sort($myArray);
echo "<h4>Output of sorted array using array sort function by values</h4>";
print_r($myArray);
/*
------------------------------------------------------------------------------
this function also assigns new keys for the array rather than reordering them
------------------------------------------------------------------------------
*/
?>
</pre>
</body>
</html>

No comments:
Post a Comment
leave your comments here..