smerny Posted November 22, 2009 Share Posted November 22, 2009 // $_POST['nums'] sample data could be "4,6,2,9,3" $nums = sort(explode(',',$_POST['nums']),SORT_NUMERIC); print_r($nums); //expect array with 2,3,4,6,9...instead got 1 why is the sort returning '1'? Quote Link to comment https://forums.phpfreaks.com/topic/182529-sort-returning-1/ Share on other sites More sharing options...
Alex Posted November 22, 2009 Share Posted November 22, 2009 sort doesn't return the sorted array, it returns a boolean indicating if it was successful or not. It takes the array by reference, so this how you would use it: $arr = explode(',',$_POST['nums']); sort($arr, SORT_NUMERIC); print_r($arr); Quote Link to comment https://forums.phpfreaks.com/topic/182529-sort-returning-1/#findComment-963400 Share on other sites More sharing options...
smerny Posted November 22, 2009 Author Share Posted November 22, 2009 ah... no wonder, thanks Quote Link to comment https://forums.phpfreaks.com/topic/182529-sort-returning-1/#findComment-963402 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.