Jump to content

[SOLVED] Check if Array Exists


phpretard

Recommended Posts

if (is_array($errormessage))
{
  foreach ($errormessage as $error)
  {
    echo $error;
  }
}

 

Or, better yet - in my opinion - declare the array at the beginning

$errormessage = array();

 

Then check the count of errors:

if (count($errormessage) > 0)
{
  foreach ($errormessage as $error)
  {
    echo $error;
  }
}

 

I think that "reads" better to a human.

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.