Jump to content

Can I optimise this loop?


Perad

Recommended Posts

if $validpages contains an array of pages and you all you want to do is see if the value of $_GET['page'] is set within that array then use in_array function instead rather than looping through the array manually.

 

If you used in_array the above code can be written as:

if(in_array($_GET['page'], $validpages)
{
    $page = $_GET['page'];
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.