I have a for loop that checks for conditions and I want to know if I can re-run an item through the loop if it doesn't meet the condition after I make some changes to variables. is it possible to add something to my else statement that will allow me to re-run the same $item under new conditions?
$array_1 = array();
$arraynumber = 0;
foreach($test_array as $item) {
if($item[2] == $test_array[$y][2]) {
$array_1[$arraynumber][] = $item;
$z++;
} else {
$arraynumber++;
$y = $y+$z;
$z=0;
echo $item[2];
}
}
The solution turns out to be this, just for those interested:
foreach($test_array as $item) {
if($item[2] == $test_array[$y][2]) {
$array_1[$arraynumber][] = $item;
$z++;
}elseif($item[2] == $test_array[$y+$z][2]){
$array_1[$arraynumber+1][] = $item;
$y = $y+$z;
$z=1;
$arraynumber++;
}else{
$array_1[$arraynumber+2][] = $item;
$z++;
$y = $y+$z;
$z=0;
$arraynumber++;
echo $item[2];
}
}