Why this is not possible to accomplish?
foreach($arr as $k => $v)
{
if($condition) { $obj->myMethod() && continue; }
}
After $obj->myMethod() gets evaluated then the keyword continue is evaluated (executed), resulting in skipping the current iteration.
EDIT: i’m asking this because something like:
if($error) { $log->fatal('Something weird happened.') && continue; }
is single line and self-explanatory.
continueis a statement not an expression.And never the twain shall meet.
You can’t put a statement in an expression. (What would
echo false && continue;print?)Instead, use an
if, which can contain statements.