- var_dump: documentation ( source)
- preg_replace_callback: documentation ( source)
<?php
$params = [':foo' => null];
$sql = 'select * from test where foo = :foo';
$sql = preg_replace_callback(
'/(?<!\b)(?<![:\\\]):(#?[a-zA-Z0-9_-]+)/',
function ($match) use ($params) {
return $params[$match[1]];
},
$sql
);
var_dump($sql);