0

Array ( [0] => John Smith )

Array ( [0] => Mary Smith )

Array ( [0] => Jack Sparrow )

I want to sort the following arrays according to its first name, (John,Mary,Smith)

However this return 111

$araySort = array($r['fullname']);
                        $sort = asort($araySort, SORT_REGULAR);
                        echo "<pre>";   
                        print_r($sort); 
                        echo "</pre>";

1 Answer 1

1

asort modifies the array by reference and returns true (1) on success. You want to accumulate all the names in the loop then call the function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.