I have an array as follows:
$list_array = array();
$list_array[] = array (
'id' => 1,
'name' => 'Sean',
'codename' => 'Maverick'
);
$list_array[] = array (
'id' => 2,
'name' => 'Matt',
'codename' => 'Diesel'
);
$list_array[] = array (
'id' => 3,
'name' => 'Bonnie',
'codename' => 'Princess'
);
I am trying to figure out how I can check to see if it's empty. I look on the site and tried a couple of things, but it's not working. Here are the things I've tried.
Attempt 1:
if (empty($list_array)
echo "Array is empty";
Attempt 2:
$arr_empty = true;
$arr_length = count($list_array);
echo "Length: " . $arr_length . "<br>";
for ($z=1; $z<=$arr_length; $z++)
{
$arr_length2 = count($list_array[$z]);
echo $z . " Length2: " . $arr_length2 . "<br>";
if (empty($list_array[$z]))
echo $z . " Is Empty<br>";
}
I feel like I'm missing the obivious here.