FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » uasort strange problem
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: uasort strange problem [message #173489 is a reply to message #173469] Fri, 15 April 2011 19:39 Go to previous messageGo to previous message
Peter is currently offline  Peter
Messages: 15
Registered: March 2003
Karma:
Junior Member
In article <io5oas$v9n$1(at)dont-email(dot)me>, jstucklex(at)attglobal(dot)net says...
> On 4/13/2011 6:34 PM, Peter wrote:
>> In article<4da60d5c$0$12063$bed64819(at)gradwell(dot)net>,
>> denis(dot)m(dot)f(dot)mcmahon(at)gmail(dot)com says...
>>> On Wed, 13 Apr 2011 19:32:15 +0100, Peter wrote:
>>>
>>>> In article<io2u9e$mi3$1(at)dont-email(dot)me>, jstucklex(at)attglobal(dot)net says...
>>>> > On 4/12/2011 6:38 PM, Peter wrote:
>>>> >> Hi all,
>>>> >>
>>>> >
>>>
>>
>> Well I was using print_r($array) to view the array as text as well as
>> using a while loop to iterate through the array from $array[0] to $array
>> [N] where N is the total unduplicated matches found.
>>
>> Anyway, thanks to Jerry for pointing me in the right direction as far as
>> uasort. It does maintain the key value associations, which I hadn't
>> noticed. Oops!! So $array[0] was moved sorted along with the rest of the
>> record data, which was not what I wanted. I needed $array[0] to hold the
>> freshly sorted lowest record, be that either first in a-z or lowest
>> price, etc.
>>
>> So I tried usort() instead and now everything works just great.
>>
>
> No, you don't. Just use foreach instead of a for loop. It will display
> the array in the sorted order.
>
> Remember - in PHP, ALL indeicies are associative - there is not an
> integer key. So item[3] could easily precede item[0], item[1] and item[2].
>
>

Ok Jerry, will give it a try.

--
Pete Ives
Remove All_stRESS before sending me an email
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Joomla, Wordpress, Expression Web
Next Topic: How can I serialize zend_http_request object?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 20:27:18 GMT 2024

Total time taken to generate the page: 0.04033 seconds