Checking the value of a key in an array

I have an array

Array
(
    [0] => Array
        (
            [building_id] => 1
            [name] => luke
            [number] => 5
            [notes] => 
        )

    [1] => Array
        (
            [building_id] => 2
            [name] => luke
            [number] => 8
            [notes] => 7
        )

)

I’m trying to show notes only if it has contennt using

foreach($buildingArray as $building) {

   if(!empty($Building['notes'])) { echo '<p class="mt-3">'.$building['notes'].'</p>';  }

ut nothing seems to rendesr

You are using a capital “B” for “building” in your check. Try a lowercase “b” as the variable is $building

3 Likes

If you’ve got a development environment you should turn on PHP logging in it. That would have shown you whats going wrong.

Warning: Undefined variable $Building

Also, a proper IDE would help too.

1 Like