Created
June 19, 2012 09:33
-
-
Save mlebkowski/2953233 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$str = "SQL :param1 :param2 END_SQL"; | |
$params = array ( | |
'param1' => 'param1 value', | |
'param2' => 'param2 value' | |
); | |
echo preg_replace_callback('/:([a-z0-9]+)/', function ($m) use ($params) { | |
return '\'' . mysql_escape_string($params[$m[1]]) . '\''; | |
}, $str) . "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment