Jump to content

maintaining clickies with zero checked produces warning/error


Recommended Posts

Posted

[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.";
}
  • Root Admin
Posted

attachicon.gifforeach_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
    }
}
Posted

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)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Forum Statistics

    17.5k
    Total Topics
    182.1k
    Total Posts
  • Recently Browsing

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
  • Recent Event Reviews

×
×
  • Create New...