You are here: Re: array multisort question « PHP Programming Language « IT news, forums, messages
Re: array multisort question

Posted by annmartinson on 08/23/06 10:05

SORRY, here is the correct array ... that's not the problem.

$final[0]['name'] = "fire";
$final[0]['value'] = 0;
$final[0]['id'] = 1;
$final[1]['name'] = "air";
$final[1]['value'] = 0;
$final[1]['id'] = 2;
$final[2]['name'] = "infinity";
$final[2]['value'] = 0;
$final[2]['id'] = 3;
$final[3]['name'] = "water";
$final[3]['value'] = 0;
$final[3]['id'] = 4;
$final[4]['name'] = "earth";
$final[4]['value'] = 0;
$final[4]['id'] = 5;

----------------------------------------------------------------
annmartinson@gmail.com wrote:
> yes, I've read and tried umpteen of the sort functions and still can't
> get it right. which one do I need???
>
> /////////////////////////////////////////////
> here is my array:
>
> $final[0]['name'] = "fire";
> $final[0]['value'] = 0;
> $final[0]['id'] = 1;
> $final[0]['name'] = "air";
> $final[0]['value'] = 0;
> $final[0]['id'] = 2;
> $final[0]['name'] = "infinity";
> $final[0]['value'] = 0;
> $final[0]['id'] = 3;
> $final[0]['name'] = "water";
> $final[0]['value'] = 0;
> $final[0]['id'] = 4;
> $final[0]['name'] = "earth";
> $final[0]['value'] = 0;
> $final[0]['id'] = 5;
>
> Within my functional code, the 'value' keys are changed dynamically
> based on returns from a form on a website. At this point, I want to
> rearrange the array SORT_NUMERICAL, SORT_DESC so that the first two
> records are the highest value. I then assign these two 'id' keys to
> separate variables and use them to post the info requested back to the
> site visitor.
>
> I've tried
> --- (1)
>
> $final2 = arsort($final[value], SORT_NUMERIC);
>
> $id = $final2[0]['id'];
> $id2 = $final2[1]['id'];
>
> ---(2)
> $final = array_multisort($final[value], SORT_NUMERIC, SORT_DESC);
>
> $id = $final[0]['id'];
> $id2 = $final[1]['id'];
>
> ---(3)
> $final2 = array_multisort($final[value], SORT_NUMERIC, SORT_DESC,
> $final[key]);
>
> $id = $final2[0]['id'];
> $id2 = $final2[1]['id'];
>
>
> every one of these gave me various errors.
>
> help is much appreciated. I'm sure the answer is MUCH simpler than I'm
> managing :)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация