我想从以下位置更改顺序:
$array = array(
"a" => "bar",
"b" => "foo",
"c" => "bar",
"d" => "foo",
"e" => "bar",
"f" => "foo",
"g" => "bar",
"h" => "foo",
"i" => "bar",
"j" => "foo"
);
至:
$array = array(
"a" => "bar", "f"=> "foo",
"b" => "foo", "g"=> "bar",
"c" => "bar", "h"=> "foo",
"d" => "foo", "i"=> "bar",
"e" => "bar", "j"=> "foo"
);
这一点是我想用数组中的项目填充一个表:
数组不应该这样排序:
<table>
<tr><td>Item 1</td><td>Item 2</td></tr>
<tr><td>Item 3</td><td>Item 4</td></tr>
</table>
但是像这样:
<table>
<tr><td>Item 1</td><td>Item 3</td></tr>
<tr><td>Item 2</td><td>Item 4</td></tr>
</table>
谢谢