Need some ideas as to how to go about sorting this array...

Posted on 16th Feb 2014 by admin

Here's how the array's are created..

Code: <?php
while ($x = readdir($dp)) {
$order[] = $p['order'];
$files[] = $x;
}
?>

Here's a sample of how they come out..

Code: Array
(
[0] => c
[1] => f
[2] => a
[3] => b
[4] => d
[5] => b
[6] =>
[7] => e
)

Array
(
[0] => learn-more
[1] => apple.php
[2] => company-info
[3] => zigzag.php
[4] => products-services
[5] => customer-support
[6] => index.php
[7] => service-agreements
)

How could I sort the files array by using the values of the order array and also make index.php always first to get something like so:

Code: Array
(
[0] => index.php
[1] => company-info
[2] => zigzag.php
[3] => customer-support
[4] => learn-more
[5] => products-services
[6] => service-agreements
[7] => apple.php
)

Other forums