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'? 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); 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 Link to comment https://forums.phpfreaks.com/topic/182529-sort-returning-1/#findComment-963402 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.