【发布时间】:2012-11-04 21:28:47
【问题描述】:
我想根据php中搜索字符串的出现对二维数组进行排序。我试图根据搜索字符串的相关性来获取数据。我遇到了比赛和反对,但它可以在MYISAM上工作,但我的桌子在innodb中。所以计划使用任何排序函数对数组进行排序,但我什么都找不到。
我的搜索压力测试字符串数组
Array
(
[0] => pressure
[1] => tes
)
与上面的字符串匹配的输出数组是
Array
(
[0] => Array
(
[title] => tests.doc
[link] => http://localhost/test.doc
[snippet] =>
)
[1] => Array
(
[title] => Pressure Testing Your Company
[link] => http://localhost/Pressure_Testing_Your_Companys.pdf
[snippet] => Questions used by the CFO against dimensions critical to success
)
[2] => Array
(
[title] => pressure.doc
[link] => http://localhost/pressure.doc
[snippet] => Templates for services
)
)
在上面的数组中,最相关的数组[1]然后数组[2]然后数组[0]应该是这个顺序。我想相应地对这个数组进行排序。 我的输出应该如下所示:
Array
(
[0] => Array
(
[title] => Pressure Testing Your Company
[link] => http://localhost/Pressure_Testing_Your_Companys.pdf
[snippet] => Questions used by the CFO against dimensions critical to success
)
[1] => Array
(
[title] => pressure.doc
[link] => http://localhost/pressure.doc
[snippet] => Templates for services
)
[2] => Array
(
[title] => tests.doc
[link] => http://localhost/test.doc
[snippet] =>
)
)
请帮帮我!!!!
【问题讨论】:
标签: php mysql multidimensional-array sorting