lundi 1 mai 2017

PHP Logic - echo IMG source using if statement

I'm struggling to understand why this is not working. Perhaps a simple php logic error?

<div class="col-md-2">
<img width="160px" src="
<?php 
    if ($output_arr_find_user_id[6] == "UNKNOWN") { 
        echo '/img/icons/devices/Device_Unknown.png';
    } else { 
        echo '/img/icons/devices/Device_6.png'; 
    } ?>
"/>
</div>

$output_arr_find_user_id[6] is Equal "UNKNOWN".

$output_arr_find_user_id[6] Comes from an array, where its value is used elsewhere. When dumped or used as an echo, a value of "UNKNOWN" is given, this proves the value is there..

The else criteria is currently NOT met and "Device_6.png" is displayed. Is my code logic wrong?

Would it be more efficient to use else if and provide an "anything else criteria"?

Aucun commentaire:

Enregistrer un commentaire