Mudsaf Posted October 23, 2013 Share Posted October 23, 2013 Hello, how i can get certain value from while loop to top of the list? I don't wanna touch SQL-query. Example my while loop result 12345 What i want 41235 Link to comment Share on other sites More sharing options...
Mudsaf Posted October 23, 2013 Author Share Posted October 23, 2013 (edited) Figured out now, made single $row variable and pasted the 4th one up there & ignored it on while loop, nvm didin't work >_> Edited October 23, 2013 by Mudsaf Link to comment Share on other sites More sharing options...
justsomeguy Posted October 23, 2013 Share Posted October 23, 2013 If you have an array of data then there are several sort functions you can use to sort the data before you loop through the array. http://www.php.net/manual/en/array.sorting.php 1 Link to comment Share on other sites More sharing options...
Ingolme Posted October 23, 2013 Share Posted October 23, 2013 This is a form of array sorting. I guess what I'd do is add the value to the beginning with array_unshift() when I found the one I was looking for. The question is how you're going to identify the value. Without more information about the problem I really can't get more specific than this: $data = array();while($row = .... ) { if($row['something'] == 4) { array_unshift($data, $row['something']); } else { $data[] = $row['something']; }} 1 Link to comment Share on other sites More sharing options...
Mudsaf Posted October 25, 2013 Author Share Posted October 25, 2013 Thanks for all replies, i will try those when i'll get back to home. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now