Re: Split command problem
| From: | Jason Wong | Date: | Mon, 11 Apr 2005 06:37:02 +0000 |
| Subject: | Re: Split command problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-212787@lists.php.net to get a copy of this message | ||
On Monday 11 April 2005 09:27, Russ wrote:
> I have been trying to get the following code working. I keep getting an
> error on line nine.
And the error is?
> It looks simular to the example in the PHP online
> manual. If I substitute a print command for line nine I get the correct
> information from $_POST[username]. I must be missing or have an extra a
> quote but I cannot figure out where.
> name($fname, $lname) = split('[/\s+/]', "$_POST[username]");
split() probably uses POSIX regex and hence knows nothing about '\s'. Use
preg_split() instead:
list($fname, $lname) = preg_split('/\s+/', $_POST['username']);
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
New Year Resolution: Ignore top posted posts