Rophs Posted February 4, 2015 Report Share Posted February 4, 2015 [attachment=4487:foreach_quest_bar_rpcq.png]\ The warning/error is not produced when atleast one clickie is clicked. This is probably because foreach doesn't know how to handle zero things. I propose a solution: try { //foreach stuff here } catch (Exception $e) { echo "You need to click the checkboxes next to the clickies you wish to maintain."; } Quote Link to comment Share on other sites More sharing options...
Root Admin Chewett Posted February 4, 2015 Root Admin Report Share Posted February 4, 2015 foreach_quest_bar_rpcq.png\ The warning/error is not produced when atleast one clickie is clicked. This is probably because foreach doesn't know how to handle zero things. I propose a solution: try { //foreach stuff here } catch (Exception $e) { echo "You need to click the checkboxes next to the clickies you wish to maintain."; } For those interested, the proper solution is: //Checks to make sure $data is an array before iterating if(is_array($data)) { foreach($data as $d) { //do somethign with $d } } Quote Link to comment Share on other sites More sharing options...
I am Bored Posted February 4, 2015 Report Share Posted February 4, 2015 Because, regardless of the language, exceptions are expensive. Of course, depending on the language, *cough*MaxScript*cough* returns, breaks, and continues can also be expensive... (for some absurd reason Autodesk implemented them using C++ exceptions internally) Quote Link to comment Share on other sites More sharing options...
Root Admin Chewett Posted February 7, 2015 Root Admin Report Share Posted February 7, 2015 Fixed. Quote Link to comment Share on other sites More sharing options...
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.