Posted: Thu Jan 12, 2006 3:04 pm
This is a challenge when using for loops and foreach loops. Normally, when I code loops like this, just before the loop, I will run an if to check for the count of the array. If there are results in the array, loop them, if not handle the exception with something else. What you end up with is code like:
Code: Select all
<?php
if (count($looparray1) > 0)
{
// There are records in the result array, loop 'em
foreach ($looparray1 as $arrayval1)
{
// ... Do something here
}
}
else
{
// ... Perform exception handling here
}
?>