Skip to content
Advertisement

Show image only if jsonObj has a value [closed]

If <?php echo $jsonObj->data->image; ?> has a value, like 1234.jpg I want to show this:

JavaScript

If <?php echo $jsonObj->data->image; ?> has no value, then <img src="https://www.example.com/img/<?php echo $jsonObj->data->image; ?>" /> should remain hidden.

Any help please?

Advertisement

Answer

Use php if-else statement for that.

JavaScript

You can add else part and do whatever you want.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement