954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to sort a string array for a given value???

Hey,

I want sort an associative array of string.

such as
array(
[hotel]=>array(
[name]='Royal Cabin'
),

[hotel]=>array(
[name]='macdonald court'
))

etc...

what want is to sort the above array to a given string such as 'ro' or 'mac'
wher the array is sorted and show the closet match in the array first, and listing others after that

Please help me on this. Thanks in adnace.

Madawa
Newbie Poster
11 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

have you tried this??
uksort — Sort an array by keys using a user-defined comparison function..
or

ksort

See this for reference:
http://in.php.net/manual/en/function.uksort.php

Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
 

Hey,

I want sort an associative array of string.

such as array( [hotel]=>array( [name]='Royal Cabin' ),

[hotel]=>array( [name]='macdonald court' ))

etc...

what want is to sort the above array to a given string such as 'ro' or 'mac' wher the array is sorted and show the closet match in the array first, and listing others after that

Please help me on this. Thanks in adnace.

always remember php.net for function other than daniweb and must remember almost all languages have ksort,sort like function to sort the array

nikesh.yadav
Posting Whiz in Training
219 posts since Feb 2008
Reputation Points: 15
Solved Threads: 21
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You