I have the below; which is meant to work like: if file type is .pdf or .doc 'Download' will appear as the button text. This works fine, but I'm stumped how to incorporate an else statement with this -- everything else, that is NOT .pdf or .doc simply display 'View' as the button text.
Any suggestions with a brief explanation would be great!
<?php
echo isset($case['pdf']) || (preg_match("/(.pdf|.doc)/", $case['link'])) ?
"Download" :"Download";
?>
The below just displays 'View' text everywhere. Either is not looking at file extension or condition is broken.
<?php
echo isset($case['pdf']) || (preg_match("/(.pdf|.doc)/", $case['link'])) ?
"Download" :"View";
?>
Note:// I am simply trying to update the code with new needs. Did not write the original, would like to just update it inline with a working condition as stated in question. Have no idea why original author went this route.
Full Code with variables:
<a href="<?php echo isset($case['pdf']) ? base_url('assets/pdf/usecases/'.$case['pdf']) : $case['link']; ?>" target="_blank" class="download-link uppercase <?php echo isset($case['type']) ? $case['type'] : '' ;?>">
<?php
echo isset($case['pdf']) || (preg_match("/(.pdf|.doc)/", $case['link'])) ?
"Download" :"View";
?>
Aucun commentaire:
Enregistrer un commentaire