自由意志で手動で記述されているため、外観で並べ替える必要のある配列があります。値は、表示されると予想されるヒントであることに注意してください。
$options = array("the array retrieved from some forms");
$items = array();
foreach ($options as $key => $val) {
switch ($key) {
case 'three':
$items[] = "this should come first";
$items[] = "now the second in order";
$items[] = "the third";
$items[] = "forth";
switch ($val) {
case 'a':
case 'b':
$items[] = "fifth";
$items[] = "should be six in order";
break;
case 'c':
default:
$items[] = "7 in order";
break;
}
break;
..............。
ご覧のとおり、値は何でもかまいませんが、必要なのは、外観に基づいてアイテムを内破して表示することです。そのすべての手動注文、最初に来るものは一番上に印刷する必要があります。
期待される:
"this should come first";
"now the second in order";
"the third";
"forth";
"fifth";
"should be six in order";
"7 in order";
現在の予期しない:
"should be six in order";
"forth";
"7 in order";
"the third";
"fifth";
"this should come first";
"now the second in order";
しかし、私はこのhttp://www.php.net/manual/en/array.sorting.phpからの並べ替えを適用できないようです。 これらの$ itemsは、並べ替える方法がないフォームによってどこかで並べ替えられていると思われます。 。上から下に好きなように出力と順序を書き込む力があります。しかし、自由に並べ替える必要があるという理由だけで、キーを$itemsに挿入することはできません。
出力を確認しましたが、キーが期待どおりに並べ替えられていません。
ヒントは大歓迎です。ありがとう