3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $search['amenities'] = array('1', '2', '3'); $amenityQuery = ''; for ($i = count($search['amenities'])-1;$i >= 0;$i--) { if (!empty($amenityQuery)) { $amenityQuery .= "(IF(`AmenitiesProperty`.`amenity_id` = {$search[amenities][$i]},$amenityQuery,0))"; } else { $amenityQuery .= "(IF(`AmenitiesProperty`.`amenity_id` = {$search[amenities][$i]},1,0))"; } } echo $amenityQuery;
Output for 4.3.0 - 7.1.0
Notice: Use of undefined constant amenities - assumed 'amenities' in /in/Pmtts on line 10 Notice: Use of undefined constant amenities - assumed 'amenities' in /in/Pmtts on line 8 Notice: Use of undefined constant amenities - assumed 'amenities' in /in/Pmtts on line 8 (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))