RE: [PHP] split string
| From: | Taylor, Stewart | Date: | Fri, 11 May 2001 07:45:52 +0000 |
| Subject: | RE: [PHP] split string | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-52415@lists.php.net to get a copy of this message | ||
$test = "1,2,3";
$arrTest = explode(",",$test);
foreach($arrTest as $k=>$v)
{
$vname = "test".(!$k?"":$k);
// global for use later
global $$vname;
$GLOBALS[$vname] = $v;
}
// now global $test, $test1, $test2 exist etc
-----Original Message-----
From: Jacky [mailto:jacky@activelifestyle.com]
Sent: 11 May 2001 16:24
To: php-general@lists.php.net
Subject: [PHP] split string
I got series of string value like this 1,2,3. And the seires are dynamaic,
which means it is not always 1,2,3 but could be more, but always in this
format that is separated by "," .
How do I pick each of value in the series and assign it into new vairiable,
like from:
$test = 1,2,3;
and assign to be
$test =1;
$test1=2;
$test2 =3;
Is theer any function that could help me with that? because I need to update
table using those value but I cannot use series of value to update, have to
break them down to each variable like that.
Jack
jacky@activelifestyle.com
"There is nothing more rewarding than reaching the goal you set for
yourself"