I have a Cookie string from a dynamic table that is looped and arrayed on the 7th index. I then check which array is empty and produce my outputs.
For the line that says $role = $array[0]; where I have the print $role. It will print what I need put it will output about 5 times.
My Attempt:
If I try to place the print $role outside the for loop it will print once and not print when other instances $role value was passed.
if (!empty($_COOKIE['arr'])) {
$arr = $_COOKIE['arr'];
$array = explode (",", $arr);
$role='';
for ($i = 0; $i < count($array ); $i++) {
for ($j = $i + 7; $j < count($array ); $j++) {
if (!empty($array[$j]) ){
print_r($array[$i]);
echo '<br>';
}
break;
}
if (empty($array[$j]) ){
print_r($array[$i]);
echo '<br>';
for ($m = 0; $m < strlen($array[$i]); $m++) {
$role = $array[0];
print $role;
break;
}
}
}
//print $role;
}