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


Posted on 16th Feb 2014 07:03 pm by admin

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

Code: <?php
while ($x = readdir($dp)) {
Did you know?Explore Trending and Topic pages for more stories like this.
$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
)
No comments posted yet

Your Answer:

Login to answer
293 Like 29 Dislike
Previous forums Next forums
Other forums

Variable Clash
In the past I've had variables clash. For example:

Code: <?php
$c = 5;
$ca

Having Problem with Date
l have a submit buttom where user have the possibility to add a date to specify when his message s

Coding Critique
I was hoping someone could take a second and look down my code and see if they see any problems with

getting most records by count
Code: [Select]<?php

$connect = mysql_connect("localhost","dam

Fatal error: Call to a member function fetchrow() on a non-object in C:xamppht
okay i have this query and everytime i add `item_id`=? to it... it gives me the error in the title..

redirect standard error and assert (how to?)
How do you redirect standard error and assert?

---

(Why? I am creating an web app and

php libs/ browsercap.in
ok i have a host that refuses to stay current. they control my php settings and libs. is there a way

Line break?
Hi, I'm new to the forum and new to php. I'm not sure if I'm using the correct terminology so here i

session variable problem
Session variable is not working in Fire fox i am getting null value but it is working fine in IE.

PHP Directory Listing Not working
Hey Guys,

I need help, I tried a ton of directory listing scripts and they all don't work. Al

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash