3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $query = "UPDATE `benefits` SET `ins_id`=:ins_id, `order`=:order WHERE `ben_id`=:ben_id"; $querydata = array(':ins_id' => 1001, ':order' => 1, ':ben_id' => 4004); echo "$query\n\n"; foreach($querydata AS $key=>$val) { echo preg_replace('/(.+?)('.$key.')(.*)/','$1' . $val . '$3', $query) . "\n"; //echo $query; }
based on Whpjh
Output for 5.3.17 - 7.2.0
UPDATE `benefits` SET `ins_id`=:ins_id, `order`=:order WHERE `ben_id`=:ben_id 001, `order`=:order WHERE `ben_id`=:ben_id WHERE `ben_id`=:ben_id 004