Jump to content

Certain value from while loop to top


Mudsaf

Recommended Posts

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

Figured out now, made single $row variable and pasted the 4th one up there & ignored it on while loop, nvm didin't work >_>

Edited by Mudsaf
Link to comment
Share on other sites

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'];    }}
  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...