0
嗨,排序多維數組由值
我有這樣的功能:
function column_links() {
$column = scandir("content");
foreach ($column as $value) {
$stvalue = str_replace(".php", "", $value);
echo "<a href=\"{$stvalue}\">{$GLOBALS['tags'][$stvalue][title]}</a>";
}
}
,這是我的變量:
define('title', 0);
define('desc', 1);
define('order', 2);
$tags = array(
'index' => array('My Page', 'this is a description', '1'),
'about' => array('About', 'this is a description', '2'),
'sitemap' => array('Site Map', 'this is a description', '3'));
我要排序的通過「order」而不是文件名生成鏈接,所以我的html看起來像這樣:
<a href="index">My Page</a>
<a href="about">About</a>
<a href="sitemap">Site Map</a>
我認爲array_multisort會做的伎倆,但我甚至不知道把它放在哪裏。請有任何想法嗎?
謝謝。
我的代碼是什麼讓你困惑? –
我只是昏昏欲睡,大部分時間都很難弄清楚你的數組的實際外觀。再看一遍,你可能想在我的例子中用['order']代替[2]。但邏輯在那裏。 –
其他人請嗎? –