Re: Split command problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux