Re: array "sort()" question, weird php behavior ?
- From: "Chung Leong <chernyshevsky@xxxxxxxxxxx>" <chernyshevsky@xxxxxxxxxxx>
- Date: 17 Jun 2005 08:57:46 -0700
The results you get is correct, given PHP's type conversion rules:
When comparing a boolean to a number, PHP converts the number to a
boolean. -1 becomes true. The order of elements with the same value
after a quicksort is undefine, hence true could come before -1.
When comparing a number to a string, PHP converts the string to a
number. "test" becomes 0, which is bigger than -1 and less than 30.
.
- Follow-Ups:
- Re: array "sort()" question, weird php behavior ?
- From: Arnaud
- Re: array "sort()" question, weird php behavior ?
- From: Arnaud
- Re: array "sort()" question, weird php behavior ?
- References:
- array "sort()" question, weird php behavior ?
- From: Arnaud
- array "sort()" question, weird php behavior ?
- Prev by Date: Re: rewriting URLs
- Next by Date: Looking for PHP code or ideas to interface with client's email application
- Previous by thread: Re: array "sort()" question, weird php behavior ?
- Next by thread: Re: array "sort()" question, weird php behavior ?
- Index(es):
Relevant Pages
|