Dont recognize variable in switch

echo $res['sobhaneid']."|".$res['naharid']."|".$res['shamid'];
     switch ($num) {
    case '1':
   
        echo $res['sobhaneid'];
   
      break;
    case '2':
    
        echo $res['naharid'];



      break;
    case '3':
       echo $res['shamid'];
      break;
    
    default:
      # code...
      break;
  }

if $num==2,the switch $res[‘naharid’]=null; but in first line $res[‘naharid’]=some value

why?

i Solved This with , put every elemennnts of $res in one variable,and now its work,

but still i dont know why it was not recognize able

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.