次の配列があるとします。
$array = array(
'note' => array('test', 'test1', 'test2', 'test3', 'test4'),
'year' => array('2011','2010', '2012', '2009', '2010'),
'type' => array('journal', 'conference', 'editorial', 'conference','conference'),
);
次の関数を使用する方が簡単な場合は、配列を簡単に変換できます。
for($i=0; $i < count($array['type']); $i++)
foreach($array as $key=> $value)
$temp[$i][$key] = $value[$i];
print_r($temp);
そして、次の基準を使用して並べ替えたいと思います。
- 配列
$sortby = ('journal', 'editorial', 'conference')
year DESC
カテゴリで並べ替えた後、カテゴリごとに並べ替えたいと思います。
望ましい結果:
Array
(
[note] => Array
(
[0] => test
[1] => test2
[2] => test1
[3] => test4
[4] => test3
)
[year] => Array
(
[0] => 2011
[1] => 2012
[2] => 2010
[3] => 2010
[4] => 2009
)
[type] => Array
(
[0] => journal
[1] => editorial
[2] => conference
[3] => conference
[4] => conference
)
)