I have a php array with mixed types like this :
$length = array (15, 3, 5, '-');
and I want to sort it to obtain a list of values sorted like this : ‘-‘, 3, 5, 15
How can I do that ?
Thanks a lot.
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.
Well, When using various mixed type in an array , you would need to set your own “priorities” of whats first and whats last.
You could use PHP’s usort function to define your own function to sort the array and define your own priorities for each data type or value.
Shai.