3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $search['amenities'] = array('1', '2', '3'); for ($i = count($search['amenities'])-1;$i >= 0;$i--) { if (!empty($amenityQuery)) { $amenityQuery .= "(IF(`AmenitiesProperty`.`amenity_id` = ".$search['amenities'][$i].",$amenityQuery,0))"; } else { $amenityQuery = '('; $amenityQuery .= "IF(`AmenitiesProperty`.`amenity_id` = ".$search['amenities'][$i].",1,0)"; } echo $amenityQuery."<br />123<br />"; }
Output for 4.3.0 - 7.1.0
(IF(`AmenitiesProperty`.`amenity_id` = 3,1,0)<br />123<br />(IF(`AmenitiesProperty`.`amenity_id` = 3,1,0)(IF(`AmenitiesProperty`.`amenity_id` = 2,(IF(`AmenitiesProperty`.`amenity_id` = 3,1,0),0))<br />123<br />(IF(`AmenitiesProperty`.`amenity_id` = 3,1,0)(IF(`AmenitiesProperty`.`amenity_id` = 2,(IF(`AmenitiesProperty`.`amenity_id` = 3,1,0),0))(IF(`AmenitiesProperty`.`amenity_id` = 1,(IF(`AmenitiesProperty`.`amenity_id` = 3,1,0)(IF(`AmenitiesProperty`.`amenity_id` = 2,(IF(`AmenitiesProperty`.`amenity_id` = 3,1,0),0)),0))<br />123<br />