2014-04-14 39 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";            
              }        
            }                                         
        } 
      }