when i print_r my array gives
Array (
[0] => Array ( [userid] => 2 [popularity] => 41.7 )
[1] => Array ( [userid] => 5 [popularity] => 33.3 )
[2] => Array ( [userid] => 7 [popularity] => 25.0 )
)
is the array returned after querying users and sort by popularity desc, meaning
user with id 2 has popularity 41.7,
user with id 5 has popularity 33.3 and so on,
Then i have a dynamic query that shows each user with his popularity
example: user with id 2 has popularity of 41.7
user with id 5 has popularity of 33.3 etc.
All i want is to show the position(outer array index) of each user if user id of dynamic query matches the output of array above then increment by 1 because array index always starts 0
example: user with id 2, will have position of 1 (the winner)
user with id 5, will have position of 2
user with id 7, will have position of 3 etc..
how can i do that...
editbutton below your question...$key+1insideforeach ($array as $key => $value) {?