简体   繁体   中英

php using foreach on an object will only run once

I have a snippet of code that will over a DatePeriod object run some code. In some situations I need to run this foreach on the DatePeriod a couple times.

foreach($objects as $object){
   foreach($period as $date){
     //do stuff
   }
}

on my development server this runs fine, when I switch to production. It will only run the first time. Every subsequent attempt will skip over the $period foreach.

I can fix this issue by unsetting the $period object and initializing it, but I rather not do that if I can avoid it.

Does anyone know why my code is behaving the way it does only on my production server?

Thanks.

Thanks for your help everyone, but I found the issue digging through php patch notes.

https://bugs.php.net/bug.php?id=52668

i'll have to see about updating to a newer version of php on my production server.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM