3v4l.org

run code in 300+ PHP versions simultaneously
<?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 = '('; $amenityQuery .= "IF(`AmenitiesProperty`.`amenity_id` = ".$search['amenities'][$i].",1,0)"; } } echo $amenityQuery;
Output for git.master, git.master_jit, rfc.property-hooks
(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))

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
37.72 ms | 401 KiB | 8 Q