RES: [PHP] Execute php commands that are in an array
| From: | Thiago Pojda | Date: | Thu, 05 Jun 2008 18:00:26 +0000 |
| Subject: | RES: [PHP] Execute php commands that are in an array | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-275073@lists.php.net to get a copy of this message | ||
I'm not sure I understand what you're trying to accomplish, but wouldn't
array_walk() help you out?
Atenciosamente,
www.softpartech.com.br
Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
thiago.pojda@softpartech.com.br
Excelência em Softwares Financeiros
-----Mensagem original-----
De: Daniel Brown [mailto:parasane@gmail.com]
Enviada em: quinta-feira, 5 de junho de 2008 14:18
Para: Ryan S
Cc: php php
Assunto: Re: [PHP] Execute php commands that are in an array
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.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php