如何切换此输出列表项的顺序。我将自定义字段值设置为“001,value”“002,value”,但最低的数字在列表中排在最后,我首先需要它。
<?php
$album = get_post_meta($post->ID, "album", false);
$album_list = get_post_meta($post->ID, "album_list", false);
foreach ($album_list as $album_list) {
list($key, $value) = explode(',',$album_list);
$indexed_album_list[$key] = $value;
}
foreach ( $album as $each_album) {
list($key,$album) = explode(',',$each_album);
echo '<div>'.$album.'</div>';
echo '<div>';
if ($album_list = $indexed_album_list[$key]) {
echo $album_list;
}
else {
echo ' ';
}
echo '</div>';
}
?>
继承人数据...... Array ( [0] => 002,Curtis [1] => 001,Get Rich Or Die Tryin [2] => 003,The Massacre [3] => 004,Before I Self Destruct ) Array ( [0] => 001, [1] => 002, [2] => 003, [3] => 004,
答案 0 :(得分:0)
Doh只需在第四行添加sort($album);
即可。