jeudi 31 mai 2018

how replace a Picture url when that return me null or nothing

i call an API of vehicle for the photos with a php GET, that return me an array,

i use this for for get the vehicle :

   $vehiculecount=count($data);
   for($x = 0; $x < $vehiculecount; $x++) { ?>

Now i want to if i have a return of the photo that return me the photo, else that return me a special "noPhoto"photo in my folder

I do this :

<?php
$photo = echo $data[$x][gallery][0][big];
if ($photo = null) {
       $photo = img/noPhoto.png;
        echo $photo;
else {
            $photo = $photo;
            echo $photo;
                                      }
  }
endif
?>

Here the HTML :

<img class="card-img-top" src="<?php echo $photo;?>" alt="">

Thx for the help.

Aucun commentaire:

Enregistrer un commentaire