Use the eval function

$string="word1 word2 word3 word4);
        
$string_array=explode(" ",$string);

for ($x=0;$x<count($string_array);$x++)

        {
                eval("\$var".$x."=\"".$string_array[x]."\";");
        }

probably needs debugging ...

Speedboy wrote:

>>$string="These are some words"
>>
>>I want it to turn into $var1=These, $var2=are, $var3=some, $var4=some
>>
> 
> $search_entities = explode(" ", $string);
> 
> if (count($search_entities) > 0) {
>       $criteria = "";
>       for ($i = 0; $i < count($search_entities); $i++) {
>               if ($i == (count($search_entities) - 1)) {
>                       $criteria .= "name = '$search_entities[$i]'";
>               } else {
>                       $criteria .= " name = '$search_entities[$i]' OR ";
>               }
>       }
> }
> $query = "select name from countries where $criteria";
> 
> I don't like this though, anyone have a better solution?
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to