[PHP] value contained within a variable contained within another variable

[PHP] value contained within a variable contained within another variable

Post by woute » Fri, 19 Sep 2003 03:59:01


You should be able to do something like this:

$kk1_current = "something";

$data = array ("kk1_current","kk2_current","mk_current");
$data_post = $$data[0]; . "\n"; // I want, $data_post = whatever

is inside $kk1_current in this example -- strval obviously doesn't work in
the case

echo $data_post;


-----Original Message-----
From: DougD [mailto: XXXX@XXXXX.COM ]
Sent: Wednesday, September 17, 2003 7:18 PM
To: XXXX@XXXXX.COM
Subject: [PHP] value contained within a variable contained within another
variable

I may be way off track with what I am trying to do, but here is my scenario
and I sure appreciate any insights.

There is a string stored in $kk1_current and I want to pull from the array
the variable name, add the "$" and then retreive the string with the
varialbe $kk1_current. This will allow to echo the contents of each varialbe
contained with the array. Make sense?

$kk1_current = "something";

$data = array ("kk1_current","kk2_current","mk_current");

$temp = "$" . $data[0];

$data_post = strval($temp) . "\n"; // I want, $data_post = whatever
is inside $kk1_current in this example -- strval obviously doesn't work in
the case

echo $data_post;


THANKS!

--
PHP General Mailing List ( http://www.yqcomputer.com/ )
To unsubscribe, visit: http://www.yqcomputer.com/