better preg_replace

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matija Papec

    better preg_replace


    I'm having trouble with regular expression readability; is there a
    better way to write preg_replace which would replace all occurrences of
    :someWord with 'addslashes($ar r["someWord"])'?


    function DBReplacePlaceh olders ($sql, &$arr) {

    return preg_replace(
    "/:(\w+)/e",
    '"\'". addslashes($arr["\1"]) ."\'"',
    $sql
    );
    }
Working...