Storing info then sorting a multi-dimensional array
Posted: Mon Jan 31, 2005 2:54 am
i have created a simple search script for my site...nothing flashy.
Anyway. During the search, i store the number of matches for the serch term and the path to that page in an array. A sample of my array looks like this.
I need to be able to sort the array so the entry with the most number of occurences is first descending the the lowest number of occurences.
1) Am i storing the values in the best way?
2) How to sort the array on the value 'ocurrences'?
Thanks
Mark
Anyway. During the search, i store the number of matches for the serch term and the path to that page in an array. A sample of my array looks like this.
Code: Select all
Array
(
ї0] => Array
(
їpath] => /data/web/_o/_c/_o/oconnordesign.co.uk/public/tsys/content/about/about_tsys.php
їoccureneces] => 4
)
ї1] => Array
(
їpath] => /data/web/_o/_c/_o/oconnordesign.co.uk/public/tsys/content/about/global_operations.php
їoccureneces] => 16
)
ї2] => Array
(
їpath] => /data/web/_o/_c/_o/oconnordesign.co.uk/public/tsys/content/about/in_europe.php
їoccureneces] => 9
)
ї3] => Array
(
їpath] => /data/web/_o/_c/_o/oconnordesign.co.uk/public/tsys/content/benefits/benefits.php
їoccureneces] => 5
)
ї4] => Array
(
їpath] => /data/web/_o/_c/_o/oconnordesign.co.uk/public/tsys/content/career_opportunities/career_opportunities.php
їoccureneces] => 3
)
ї5] => Array
(
їpath] => /data/web/_o/_c/_o/oconnordesign.co.uk/public/tsys/content/contact/contact.php
їoccureneces] => 4
)
ї6] => Array
(
їpath] => /data/web/_o/_c/_o/oconnordesign.co.uk/public/tsys/content/culture/history.php
їoccureneces] => 8
)
)1) Am i storing the values in the best way?
2) How to sort the array on the value 'ocurrences'?
Thanks
Mark