PDA

View Full Version : [PHP] Problema con Array


x3d0
04-09-2009, 12:13
Ho un Array multidimensionale formato in questo modo


"id" => 4
"type" => 1
"nome" => 'prova'
"descrizione" => 'etc..'


"id" => 5
"type" => 1
"nome" => 'prova'
"descrizione" => 'etc..'


"id" => 6
"type" => 2
"nome" => 'prova'
"descrizione" => 'etc..'

Quello che devo fare č ottenere un'altro array contenente solamente i sotto array che hanno type = 1. Quindi quelli con ID 4 e 5. Come fare?

x3d0
04-09-2009, 13:02
Risolto cosė


function GetSupplementsRows($type){
foreach($this->supplements_rows as $supp => $info){
foreach($info as $label => $value){
if(($label == 'type') and ($value == $type)){
$final_array[] = $info;
}
}

}
return $final_array;
}