when sort an array with letter and number, like below:
$a = array(0, 1, ‘a’, ‘A’);
sort($a);
print_r($a);
the result confuse me like that:
Array ( [0] => a [1] => 0 [2] => A [3] => 1 )
why the ‘0’ between in ‘a’ and ‘A’?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you do that, the numbers are converted to a string. Number character ASCII values come between the two cases.The strings are converted to numbers. It takes any number characters at the beginning and drops everything else to compare, unless it finds ‘.’,’E’, or ‘e’, which can be used for floating-point conversion. If it finds no numeric characters, it evaluates to zero.