tmpid)) { $this->tmpid = 0; } } public function loadtmp(){ if(empty($this->tmpid)) { return false; }else{ if(is_numeric($this->tmpid)) $sql = "select id,body from emailtext where id='".$this->tmpid."'"; else $sql = "select id,body from emailtext where template='".$this->tmpid."'"; $rs = $this->db->query($sql); $c = $rs->fetch(); if(!empty($c['id'])) { if(count($this->data)==0) { return false; } else { $patterns = array(); $replacements = array(); foreach($this->data as $k=>$v) { $patterns[]='/{'.$k.'}/i'; $replacements[]=$v; } ksort($patterns); ksort($replacements); $newString=preg_replace($patterns, $replacements, $c['body']); return $newString; }//count($this->data) } else { return false; } }//empty($this->tmpid) }//function loadtmp }