Tiago Diaz - 2009-10-08 02:04:23
Well to understood what i am trying... Run the code above!
<?php
class teste{
var $rep;
public function sql($sql_){
$this->rep['id'] = '0';
$this->rep['name'] = "'teste'";
$this->rep['text'] = "'testando...'";
return $this->returnSQL($sql_,$this->rep);
}
public function returnSQL($sql,$rep){
return preg_replace_callback("/%([A-Za-z0-9]*)%/",create_function('$arr','global $rep; return $rep[$arr[1]];'),$sql);
}
}
$temp = new teste();
echo $temp->sql("SELECT * FROM teste WHERE id = %id% AND temp = %text% AND temp_3 = %text% AND temp_1 = %name%");
?>
I need to get the $this->rep from inside the preg_replace_callback with the create_function, but i tryed everything i can, but nothing worked, i am really desesperated... needing an urgent help!