How to stop a loop PHP

后端 未结 4 680
没有蜡笔的小新
没有蜡笔的小新 2021-01-29 06:10

I\'m trying to figure out if its possible to stop a foreach loop in PHP, like this,

$arr = array(\'Joe\', \'Jude\', \'James\', \'Pitch\', \'Tim\');
$i=0;
foreach         


        
4条回答
  •  太阳男子
    2021-01-29 06:55

    1)As said earlier u need to increment the loop. 2)...if ur using multiple "foreach" that are nested,you can do break 'n' to get out of n nested loop,where n will specify any number from 1 to the total number of loops that you have used.Hope it helps!

提交回复
热议问题