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)) {
$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

Mysql query, two times?
Hello to all,

I'm new to php coding and i like it alot. I need help with some noob stuff.

images aren't rendering
I'm trying to call a JPG file from within PHP (in an effort to hide the actual JPG folder). The imag

File upload issues
Hi Guys,

Can anyone see any issues with this code:
Code: [Select]$setImage= 'productimages

Preventing blank or already entered values
Im trying to learn how to place a read file line by line and prevent duplicate entries and also BLAN

a dificult string search
Hi I don't know a way around this. I want the user to input a password, but to make it a bit complca

Something Non-Traditional. Can we solve?
I have an idea for an application here. It's mostly flash, but it couldn't work without a somewhat n

How to Create a Dynamic table
col1 col2 date1 date2 date3 date4..........
a b v1 v2 v3 v4

Alternate messaging
I have 4 strings in MySQL db1

$string1 : Hello
$string2 : Hi
$string3 : Great
$strin

While Problem
i am having a problem with a while statement here is the code
Code: [Select]<?php
sess

include function being weird?
I have a very simple system to grab an IP outputted by a PHP file.. (for a project I have) but it ou

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