Hi all i have the following array:
var $status = array('pending' => array('code'=>1,'t_sys_lang'=>248),
'approved' =>array('code'=>2,'t_sys_lang'=&g开发者_Go百科t;214),
'rejected' =>array('code'=>3,'t_sys_lang'=>252));
how can get t_sys_lang value(248,214....) if i only have the code value(1,2,...) ?
function getTSLByCode($code) {
foreach ($GLOBALS['status'] as $k=>$v) {
if ($v['code'] == $code) return $v['t_sys_lang'];
}
return false;
}
$t_sys_lang = getTSLByCode( //code );
$array = array(1,2,3);
foreach ($status as $v)
if (in_array($v['code'],$array)) echo $v['t_sys_lang'];
精彩评论