note 16438 deleted from function.eval by jimw

From: Date: Tue, 30 Oct 2001 18:35:48 +0000
Subject: note 16438 deleted from function.eval by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-19614@lists.php.net to get a copy of this message
Hello! I was asked how to solve this problem: <br> "How would I 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)

« previous php.notes (#19614) next »