Jump to content

maintaining clickies with zero checked produces warning/error


Rophs

Recommended Posts

[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.";
}
Link to comment
Share on other sites

  • Root Admin

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
    }
}
Link to comment
Share on other sites

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.5k
    Total Posts
  • Recently Browsing

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
  • Recent Event Reviews

×
×
  • Create New...