开发者

retrieving code from array of array

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'];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜