codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?php $array = array( 'note' => array('test', 'test1', 'test2', 'test3', 'test4'), 'year' => array('2011','2010', '2012', '2009', '2010'), 'type' => array('football', 'basket', 'football', 'basket','football'), ); for($i=0; $i < count($array['type']); $i++) foreach($array as $key=> $value) if (isset($value[$i])) $temp[$i][$key] = $value[$i]; print_r($temp); $sortBy = array('basket','football'); foreach($temp as $key=>$row) { $type[$key] = array_search($row['type'],$sortBy); $year[$key] = $row['year']; } array_multisort($type, SORT_ASC, $year, SORT_DESC, $temp); print_r($temp); for($i=0; $i < count($temp); $i++) foreach($temp[$i] as $key=> $value) $temp2[$key][$i] = $value; print_r($temp2) ?>
Private
[
?
]
Run code
Submit