Two ways I can think of off the top of my head:

    $s = "('item','item2','item3')";
    preg_match_all("/'(.*?)'/",$s,$regs);
    $result = $regs[1];

or

    $s = "('item','item2','item3')";
    eval('$result = array'.$s.';');

Neither is very efficient though.  eval() is particularly ugly.

-Rasmus

On Tue, 13 Aug 2002, Alexander Ross wrote:

> If I have a string variable that is already of the form
> ('item','item2','item3')   [including the parens and quotes in the string],
> is there an easy way to change that variable into an array??
> Array($var) doesn't work. Thanks
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to