Category Archives: PHP

rsort

It  sorts the array in reverse order

Example

<?php
echo “<pre>”;
$lan = array(“PHP”,”JSP”,”ASP”);
rsort($lan);
print_r($lan);
?>

Output

Array
(
[0] => PHP
[1] => JSP
[2] => ASP
)

range

It can be used to create an array containing a range of elements

Example

<?php
echo “<pre>”;
$array = range(3, 7);
print_r($array);
?>

Output

Array
(
[0] => 3
[1] => 4
[2] => 5
[3] => 6
[4] => 7
)

natsort

It sorts an array using a “natural order” algorithm

Example

<?php
echo “<pre>”;
$lan = array(“PHP”,”JSP”,”ASP”);
natsort($lan);
print_r($lan);
?>

Output

Array
(
[2] => ASP
[1] => JSP
[0] => PHP
)