Find order of data inside an array
- by user271619
I have a simple array of stuff:
$array = array("apples","oranges","strawberries");
I am trying to find the order of the stuff inside the array. (sometimes the order changes, and so do the items)
I'm expecting to get something like this:
"apples" = 0,
"oranges = 1,
"strawberries = 2
The end result has something to do with database sorting.
Something like this, inside a foreach loop:
UPDATE tbl SET sortorder = $neworder WHERE fruit = '$fruitname'
The $neworder variable would be populated with the new order, inside the array. While the $fruit variable comes from the item inside the array.