Title: Run PHP code
Last modified: August 19, 2016

---

# Run PHP code

 *  Resolved [Lorrens](https://wordpress.org/support/users/lorrens/)
 * (@lorrens)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/run-php-code-1/)
 * 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!!

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/run-php-code-1/#post-1414403)
 * Variable variables are what you’re after i believe…
    [http://php.net/manual/en/language.variables.variable.php](http://php.net/manual/en/language.variables.variable.php)
 *  Thread Starter [Lorrens](https://wordpress.org/support/users/lorrens/)
 * (@lorrens)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/run-php-code-1/#post-1414405)
 * Thanks mate, I think this is it!
 * Just starting with PHP… having some troubles 😉
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/run-php-code-1/#post-1414409)
 * Try to avoid eval, chances are if you need to use it to do something basic, you’re
   going about it the wrong way..
 * Happy to help though.. 😉
 *  Thread Starter [Lorrens](https://wordpress.org/support/users/lorrens/)
 * (@lorrens)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/run-php-code-1/#post-1414414)
 * Thank you t31os_ – You’re my hero =D
 * This is what I needed:
 *     ```
       foreach ($s as $value) {
       	if ($i < $max) { 
   
       	$var = $t[$i];
       	$name = $var ;
       	$$name = $value;
   
       	$i++;
       	}
       }
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Run PHP code’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [Lorrens](https://wordpress.org/support/users/lorrens/)
 * Last activity: [16 years, 2 months ago](https://wordpress.org/support/topic/run-php-code-1/#post-1414414)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
