mercredi 24 mai 2017

PHP if nothing displays in if statement

Here is my array:

Array
(
    [0] => Array
        (
            [id] => 5
        )

    [1] => Array
        (
            [id] => 9
        )

    [2] => Array
        (
            [id] => 2
        )

here is my PHP code:

<?php
foreach($results as $row) {
    if($row['id'] > 10) {
        echo $row['id'];
    }
}
?>

since there is no id that is greater than 10, i want it to:

echo 'Nothing found';

how can i do that? thanks.

Aucun commentaire:

Enregistrer un commentaire