i have a multiple array.. the output looks like this:
Array
(
[0] => Array
(
[0] => AdsBot
[1] => 7
)
[1] => Array
(
[0] => SurveyBot
[1] => 1
)
[2] => Array
(
[0] => bingbot
[1] => 3
)
[3] => Array
(
[0] => bot
[1] => 27
)
what i need now is to sort arrays by there number.. so it should look exactly like this:
Array
(
[0] => Array
(
[0] => bot
[1] => 27
)
[1] => Array
(
[0] => AdsBot
[1] => 7
)
[2] => Array
(
[0] => bingbot
[1] => 3
)
[3] => Array
(
[0] => SurveyBot
[1] => 1
)
i need to sort it by the numbers array key.. but i really dont know how- well, i'm new to php
the multi. array code :
$bot_array = [
['name' => 'bingbot', 'number' => $bingbot],
['name' => 'googlebot', 'number' => $googlebot],
['name' => 'robots.txt', 'number' => $robots_txt],
['name' => 'exabot', 'number' => $exabot],
['name' => 'bot', 'number' => $bot],
['name' => 'robot', 'number' => $robot],
['name' => 'BaiDuSpider', 'number' => $BaiDuSpider],
['name' => 'Yahoo Slurp', 'number' => $yahoo_slurp],
['name' => 'AdsBot', 'number' => $adsbot],
['name' => 'SurveyBot', 'number' => $surveybot],
['name' => 'scanner', 'number' => $scanner],
['name' => 'checker', 'number' => $checker],
];
or maybe there is a more smarter way to do this? i need this for a top ten :) on the left should be written all the names and at the right the quantity
thanks for any help :)
EDIT:
$tmp = Array();
foreach($bot_array as &$ba)
$tmp[] = &$ba["number"];
array_multisort($tmp, $bot_array);
foreach($bot_array as &$ba)
echo $ba["number"]."<br/>";
i did this but it still doesnt sort it like i want it..
0
0
0
1
10
12
27
3
3
5
7
9
this is what it gives me now :o