note 12012 rejected and deleted from function.ereg-replace.php by philip

From: Date: Mon, 27 Aug 2001 12:29:22 +0000
Subject: note 12012 rejected and deleted from function.ereg-replace.php by philip
Groups: php.notes 
Request: Send a blank email to php-notes+get-17188@lists.php.net to get a copy of this message
This will do the job :-) ereg("<%([^*]*)%>", $text, $regs); $text = str_replace("<%".$regs[1]."%>", ${$regs[1]}, $text); ------------ Try using the PHP str_replace function. For instance, you can do $text = str_replace("<%Name%>", $name, $text); ------------ I would to replace such Strings "<%String%>" from a HTML-template with the value of $String. i.e. $Name = "Steve" "Hello <%Name%>..." should be replaced with "Hello Steve". This don't works: $text = ereg_replace("<%([^*]*)%>", "${'\1'}", $text); Does anybody knows a code, that works?

« previous php.notes (#17188) next »