I'm creating a formulary with a lot of things into it and i've a simple problem with my foreach.
Here is my code :
foreach($aDonnes['Grilles'][$iGrilleId] as $iCptGrille){
$sHtml .='<tr><td class="grille">'.($sGrilleLib=$aDonnes['Grilles'][$iCptGrille][1]).'</tr></td>';
$aDonnes['Domaines']=$oRolling->find_domaines($iCptGrille);
if ($iCptGrille < $aDonnes['Grilles'].length) {
$iCptGrille++;
}
// Several nested foreach
I've tried without the if condition, or anything and it still doesn't increment when I check the logs, It just do the same thing again and again.
If you've any questions feel free to ask.
NB : $iCptGrille is my int that doesn't increment and aDonnes is an array that has a lot of data into it, and in our case this is for each ID of my Table called "Grille" that i want to loop.
If you are checking a 2D array, I think the foreach input should be:
foreach($aDonnes['Grilles'] as $iCptGrille){...}
Also the counter name has the same name as the object item $iCptGrille, which doesn't make sense.
Also you can try initializing the counter by 0 before foreach block and remove 'if' statement if it's unnecessary.
For furthur investigations, you can use some kind of flag (for example echo 'entered';
) inside the foreach block, to make sure it enters into the foreach block.
I hope it helps.
正如Answers_Seeker所说,“这是范围的问题:使用as关键字可以复制实际的数组元素”。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.