多维数组与变量的比较

Hi there i'm having some issue regarding comparison between a 2D array and a variable declared as $thold. when ever i tried to compare only the if or the only else work.The code is..

for($i = 0; $i < $lvalue; $i++){
     for($j = 0; $j < $lvalue; $j++){
        if($array[$i][$j] > $thold){
         $array[$i][$j]=0;
         echo $array[$i][$j]."&nbsp;&nbsp;&nbsp;&nbsp;";
       }
       else{
        $array[$i][$j]=1;
        echo $array[$i][$j]."&nbsp;&nbsp;&nbsp;&nbsp;"; 
       }
     }

Try foreach and referenced values (not tested):

 foreach($lvalue as $i => &$inner){
     foreach($inner as &$val){
         if($val > $thold){
             $val = 0;
             echo $val."&nbsp;&nbsp;&nbsp;&nbsp;";
         }else{
             $val = 1;
             echo $val."&nbsp;&nbsp;&nbsp;&nbsp;";
         }
     }
 }