I've two arrays:

```
$rooms = [1,2,3,4,5,6,7,8,9];
$reserved_rooms = [4, 7]; 

```

I would like to print this array like this:

```
1
2
3
Room 4 is reserved
5
6
Room 7 is reserved

```

Her is my code:

```
$rooms = [1,2,3,4,5,6,7,8,9];
$reserved_rooms = [4, 7]; 

foreach($rooms as $key=>$val){
    foreach($reserved_rooms as $val2){
        if($val == $val2){
            echo $val2." room is reserved";
        }   
        else
            echo $val."<br>";
    }
}

```

The result is:

```
1
1
2
2
3
3
4 room is reserved4
5
5
6
6
7
7 room is reserved8
8
9
9

```