note 12012 added to function.ereg-replace.php

From: Date: Sun, 18 Mar 2001 19:10:48 +0000
Subject: note 12012 added to function.ereg-replace.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-12526@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? http://www.php.net/manual/en/function.ereg-replace.php

« previous php.notes (#12526) next »