I'm able to iterate over a PHP array using foreach, but not with a for loop:
this does not work:
for($j = 0; $j < sizeof($jobsFilterA); $j++) {
echo $j . $jobsFilterA[$j] . "<br>";
}
this does:
foreach($jobsFilterA as $job) {
echo $job . "<br>";
}
I've got 5 different arrays, some of which were simply built from database extract, others built then trimmed by removing specific indices.
Getting the feeling I've just got empty indices due to use of the unset function now that I type this all out.
Can I remove unset indices or how would be the proper way of rebuilding the array?
Thanks in advance!
Tried iterating over multiple different arrays in different ways.
Code is above.
Unset indices in the for loop throw an undefined offset exception/error.
In the end, these 5 arrays need to be echoed into a table. I've been doing that via a for loop like so:
/*
* Echo data into a table
*/
echo '<tbody>';
for($i=0; $i < sizeof($jobsFilterA); $i++){
echo "<tr><td>" . strtoupper(substr($custLastNames[$i], 0, 4)) . "</td>";
echo "<td width='100'>" . $jobsFilterA[$i] . "</td>";
echo "<td>" . $waxDueDates[$i] . "</td>";
echo "<td>" . $dayDifferences[$i] . "</td>";
echo "<td>" . $revisedETAs[$i] . "</td></tr>";
}
echo '</tbody>'
which is why I'm hoping I can reorganize the arrays so that their data is indexed in alignment/with continuity.