Expand Variables in String
| From: | Daniel Kolbo | Date: | Wed, 29 Jul 2009 20:43:27 +0000 |
| Subject: | Expand Variables in String | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-296030@lists.php.net to get a copy of this message | ||
Hello,
Is it possible to force a string to expand variable names after the
string has been set and before the variable's been defined without
having to do a string replace or preg_replace?
for example,
<?php
$str = "some string and some \$var plus other stuff";
echo $str."<br />";
$var = "Variable Contents";
echo $str."<br />";
$str_expanded = $str;//would like this to expand $var into $str_expanded
echo $str_expanded."<br />";
?>
Thanks,
dK
`