On Sun, Nov 30, 2003 at 01:04:08PM -0800, Ian Truelsen wrote:
> On Sun, 30 Nov 2003 21:44:50 +0100
> "Bronislav Klucka" <[EMAIL PROTECTED]> wrote:
>
> > The temperature is $$temp
> >
> Unfortunately, that is not working for me. I have tried changing it in
> the text file, but that just outputs $$temp instead of the value of
> $temp. What I have is the array words, for which the relevant entry is
> words[3] being equal to "$temp". What I need to be able to do is to
> print $words[3]; in such a way that it outputs the value of $temp and
> not the value of $words[3].
>
> I also tried print $$words[3] but that outputs nothing. I tried print
> $($words[3]); but that gives a parse error. And print ${$words[3]}
> prints out nothing.
Use eval. http://www.php.net/eval
% cat temp.txt
Temperature $temp degree.
% cat temp.php
<?php
$temp = '5';
$filename = "./temp.txt";
$handle = fopen ($filename, "r");
$code = fread ($handle, filesize ($filename));
fclose ($handle);
print $code."<br>";
eval("\$result = \"".addslashes($code)."\";");
echo $result;
?>
-- zhuravlev alexander
u l s t u n o c
([EMAIL PROTECTED])
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php