Run PHP code
-
Hi,
I’d like to ‘run’ some php code. I now load two arrays via a get, this is working like a charm. The first get is ‘name’ with values like:
‘johnson’, ‘jordan’, ‘brown’, ‘daniels’, etc.
The second get is ‘vars’ with values like:
‘old’, ‘young’, ‘ugly’, ‘great’.I would like to combine these gets as new variables:
$johnson = “old”;
$jordan = “young”;
$brown = “ugly”;Both gets give me 28 values, and the first value from the first get corresponds with the first value from the second get.
But now, I want to use those variables in my page, but I can’t get that to work. I would like to use <?php echo $johnson; ?>, which would output old.
So far, I got this code:
<?php $name = $_GET["name"]; $name = urldecode($name); $s = explode("|", $name); $vars = $_GET["vars"]; $vars = urldecode($vars); $t = explode("|", $vars); $i = 0; $max = "28"; foreach ($s as $value) { if ($i < $max) { $hooray = $t[$i]; $varial = "\$" . $hooray . "=\"" . $value . "\";"; eval("?>".$varial."<?"); $i++; } } ?>
But the only thing that does is show me al the variables. Output:
$johnson = “old”;
$jordan = “young”;
$brown = “ugly”;But I don’t want it as output, I want it treated as real php code, so I can use the variables!
Is there anybody who can help me with this?
Thank you!!
- The topic ‘Run PHP code’ is closed to new replies.