Ron Piggott wrote:
I need help to know how to sort the words / phrases in my array.
Variable name: $words_used
print_r( $words_used ); Current output: Array ( [187] = Sin [249] =
Punished [98] = Sanctuary [596] = Sing [362] = Anointing Oil ) Desired
result: Alphabetical sort: Array (
Also check http://www.php.net/manual/en/function.natsort.php
On Tue, Mar 1, 2011 at 1:39 PM, David Robley robl...@aapt.net.au wrote:
Ron Piggott wrote:
I need help to know how to sort the words / phrases in my array.
Variable name: $words_used
print_r( $words_used ); Current output:
That or do it in mysql before you get the data back, its also pretty good at
sorting, you know ;)
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
FeIn aci...@gmail.com wrote:
Also check http://www.php.net/manual/en/function.natsort.php On Tue, Mar 1,
2011 at 1:39 PM,
Stupid as I was, I did not do what I should have done :) In the origin the
array was created from a MySQL database. I did not sort it correctly from
there because I did not have the knowledge about the GROUP BY command, so I
tried to solve it via PHP. Now I have everything sorted and alright just
Peter Lauri wrote:
I have an multidim array that looks something like this:
[40] = [1]=32, [2]=55, [total]=87
[22] = [8]=2, [7]=105, [total]=107
[142] = [2]=3, [7]=8, [total]=11
I want to sort this array according to the total and still keep the
acc. with the basekey. I know I can easily do this
The problem was more complex than I described, I instead wrote a sorting
algorithm for this specific purpose.
The array multi-dim array looks like this (short version). The total element
is just the sum of the other. This is a point system for golftournaments. I
wanted to sort them first on total
Peter Lauri wrote:
The problem was more complex than I described, I instead wrote a sorting
algorithm for this specific purpose.
The array multi-dim array looks like this (short version). The total element
is just the sum of the other. This is a point system for golftournaments. I
wanted to sort
Peter Lauri wrote:
Best groupmember,
I have an multidim array that looks something like this:
[40] = [1]=32, [2]=55, [total]=87
[22] = [8]=2, [7]=105, [total]=107
[142] = [2]=3, [7]=8, [total]=11
I want to sort this array according to the total and still keep the acc.
with the basekey. I know I
I have tried to figure it out how to use it with those, but I can not find a
solution.
- Best Of Times
/Peter
Sebastian Mendel [EMAIL PROTECTED] skrev i meddelandet
news:[EMAIL PROTECTED]
Peter Lauri wrote:
Best groupmember,
I have an multidim array that looks something like this:
I have tried to figure it out how to use it with those, but I can not find a
solution.
- Best Of Times
/Peter
Sebastian Mendel [EMAIL PROTECTED] skrev i meddelandet
news:[EMAIL PROTECTED]
Peter Lauri wrote:
Best groupmember,
I have an multidim array that looks something like this:
the way i did this was by structuting the array like this
$array['href'][0] = 'www.com.com';
$array['description'][0] = 'blah!';
etc...
then use the array_multisort function like this
To sort by href:
array_multisort($array['href'],$array['description'],$array['time']);
a key point is that the
You want to use usort, which lets you specify a comparison function.
function cmpByLength($a, $b) {
return strlen($a) strlen($b);
}
usort($arrayToSort, 'cmpByLength');
And change the '' to '' if the ordering is wrong.
Rolf Brusletto wrote:
Hey all -
I've been scouring the php.net site for a
hi,
try usort();
ciao SVEN
JiøîÆèî eË wrote:
hello,
i have got a problem, tehere is an array:
$x = array(
array(15,55,array(1,2,3),3,5,array(1,2,5)),
array(25,55,array(1,2,3),3,5,array(1,2,5)),
array(5,55,array(1,2,3),3,5,array(1,2,5))
);
and I need to sort this arraybz
On Thu, 13 Sep 2001 11:10:03 +0200 impersonator of
[EMAIL PROTECTED] (_lallous) planted I saw in php.general:
here's your script,
..
Kill 'em All
The Wall;
$mem = split(\n, $mem);
Explode() is less expensive then split(), as long as you don't use regexp,
which is the case here, and (from the
here's your script,
?
$mem = The Childhood
A Man called lallous
The Long kiss good night
Abbey Road
Dark Side Of the Moon
The Final Cut
The Zombie
A Hard Days Night
Kill 'em All
The Wall;
$mem = split(\n, $mem);
$arr1 = array();
for ($i=0;$icount($mem);$i++)
{
$line = trim($mem[$i]);
another case-insensitive version:
pre
?
$mem = The childhood
A Man called lallous
The Long kiss good night
Abbey Road
Dark Side Of the Moon
The Final Cut
The Zombie
A Hard Days Night
Kill 'em All
The Wall;
$mem = split(\n, $mem);
$arr1 = array();
for ($i=0;$icount($mem);$i++)
{
$line =
16 matches
Mail list logo