Jump to content

move onto next item in loop without a bunch of if statements?


dadamssg87

Recommended Posts

Is there a way to tell the loop you are iterating through to move onto the next item if a certain condition is met without having a bunch of nested if statements?

 

<?php

foreach($item as $key => $value)
{
//code to manipulate the data

if($data == $condition1){ //move on to next item}

//manipulate data more

if($data == $condition2){ //move on to next item}

//manipulate data even more

if($data == $condition3){ //move on to next item}

//you get the idea

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.