note 16511 deleted from function.eval by zak
| From: | zak@php.net | Date: | Fri, 02 Nov 2001 12:28:53 +0000 |
| Subject: | note 16511 deleted from function.eval by zak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-20300@lists.php.net to get a copy of this message | ||
Suppose you need to turn a string like "this string text blah" into 4 different variables
e.g. $var1=this, $var2=string, etc. etc...
<br>
The solution is:
<?
$string = "this string text blah";
$array = explode (" ", $string);
for ($i = 0; $i < count($array); $i++)
{
$val = $array[$i];
$j = $i+1;
eval ("\$var$j = \$val;");
}
echo "$var1, $var2, $var3, $var4";
?>
will print:
this, string, text, blah
Happy codding! buddy (Lukas Kyzlink)