$foods = array(
'meat' => array('burgers', 'steak', 'sausages', 'liver'),
'cake' => array('victorian', 'chocolate', 'fruit', 'fudge')
);
I want just the meat values in reverse alphabetical order and the function should return an array.
and I don't want the liver to be included in the array.
How can I do that?
I have done this but for some reasons I didn't like it. Looks very simple to me. can any one please suggest me a better way of doing that. This is how I did it.
function items($arr){
$x = $arr['meat'];
sort($x);
$z = array_reverse($x);
foreach ($z as $v){
if($v == 'liver')continue;
$r[] = $v ;
}
return $r;
}
$foods = array(
'meat' => array('burgers', 'steak', 'sausages', 'liver'),
'cake' => array('viian', 'chocolate', 'fruit', 'fudge')
);
$x = items($foods);
var_dump($x);
?>