AFVA | Mitchell Posted January 21, 2010 Report Posted January 21, 2010 Just wondering if anyone had the code to stop the Invalid argument supplied for foreach() and instead replacing it with 'No routes found' when no results are returned. I used to know the code but forgot it. Thanks! Quote
Administrators simpilot Posted January 21, 2010 Administrators Report Posted January 21, 2010 How about -> <?php if (!$variable) {do something if the array is empty} else {do something if the array has data} ?> Quote
Administrators Nabeel Posted January 21, 2010 Administrators Report Posted January 21, 2010 I would use: if(!is_array($variable)) { echo 'No routes found'; return; } Though you can also use !$variable I'm updating my code to use !is_array() though Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.