mercredi 27 novembre 2019

Replace string with PHP if statement

I have a API which outputs property (real estate) data from a central database into my website. I want to replace the names of some property types, with my own names. I have this code:

<?php echo isset($property['ROLType']) ? $property['ROLType'] : (isset($property['PropertyType']['NameType']) ? $property['PropertyType']['NameType'] : '-'); ?>

This category has many names/types of properties in it. One of them is "Detached Villa" which i would like to change to just "Villa".

I have tried with this, but no luck:

<?php echo isset($property['ROLType']) ? $property['ROLType'] : (isset($property['PropertyType']['NameType']) ? $property['PropertyType']['NameType'] : '-'); ?>

<?php
if(isset($wprow_details['Property']['ROLType'])){
if($wprow_details['Property']['ROLType'] == 'Detached Villa'){
echo 'Villa';
}?>

What am i doing wrong?

Aucun commentaire:

Enregistrer un commentaire