2014-04-14 81 views
-1

我的foreach失去了我的價值後,如果PHP失去價值後,如果

foreach ($etc_uloziste as $id => $etc_id) { 
    foreach ($etc_id as $id2 => $etc_id2) { 
     if($rodic1==$id) { 
      if(! in_array($etc_id2, $etc_mn)) { 
       //Check if the season already is displayed 

       $sql.= ",\n"." ".$etc_id2."_id"." INT"; 

       $etc_mn[] = $etc_id2; //Store the season in the array 
      } 
     } 
    } 
} 

之前,如果我有這樣的值:

[book] => Array 
     (
      [0] => library 
      [1] => room 
     ) 

但如果後只有

[book] => Array 
     (
      [0] => library 
     ) 

$ etc_id2就像圖書館或房間,$ id是圖書

+0

你可以的var_dump $ etc_uloziste變量,所以我們可以看看它的結構?我有一種感覺,你錯誤地循環着它。 – Fadey

+0

這是我的$ etc_ulozis http://pastebin.com/zhZKsP1B – user3492956

+0

你試圖做什麼? – Fadey

回答

0

我失去了2值呼應

foreach ($result2 as $rodic1 => $rodic_hodnot1) 
      {   
      foreach ($etc_uloziste as $id => $etc_id) 
        {       
            foreach ($etc_id as $id2 => $etc_id2) 
            {         
             //echo $etc_id2."\n";         
             if($rodic1 ==$id) 
              { 
              //echo $etc_id2."\n";            
              }        
            }                                         
        } 
      }