Re: Execute php commands that are in an array
| From: | Daniel Brown | Date: | Thu, 05 Jun 2008 17:17:43 +0000 |
| Subject: | Re: Execute php commands that are in an array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-275071@lists.php.net to get a copy of this message | ||
On Thu, Jun 5, 2008 at 12:34 PM, Ryan S <genphp@yahoo.com> wrote:
> Hey,
> its easier to start with code and then explain:
>
> $t_array[]='chr(rand(97,122))';
> echo $t_array[0];
>
> The above code outputs
> chr(rand(97,122))
>
> How can i execute that above code from the array instead of displaying it?
Try using create_function().
<?php
$t_array[] = create_function('','echo chr(rand(97,122));');
echo $t_array[0];
?>
Note the manner in which the second parameter is laid-out. You
must include what you want returned by the dynamic function, complete
with an ending semicolon.
--
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.