[PHP] Re: Extract data

2001-12-04 Thread CC Zona

In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Dan) 
wrote:

 Warning: unexpected regex error (14) in c:\program files\apache 
 group\apache\htdocs\eztatic\poll.php on line 25
 
 25: list(q1,q2,q3,q4,q5)= split (|, $answer, 5);

Split() takes a regex as the first argument.  The pipe character (|) is a 
special character in regex, so it needs to be escaped if you intend to use 
it as a string literal.

But, as noted in the docs 
http://www.php.net/manual/en/function.split.php: ...if you don't require 
the power of regular expressions, it is faster to use explode(), which 
doesn't incur the overhead of the regular expression engine.

-- 
CC

-- 
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]




[PHP] Re: Extract data

2001-12-04 Thread J Smith


For a split this simple, I'd recommend using explode(|, $data). split() 
uses a regex for the first character (and as others have said, the pipe is 
a metacharacter in a regex, so you'll need to use \| instead of |), 
whereas explode() is simply literal. explode() will probably be slightly 
faster, too, since it doesn't need to compile the regex, etc., although the 
difference will probably be infintesimal.

J



Dan wrote:

 Hello guys
 
 I'm making poll script that stores  data like this:
 
 0|0|0|0|0
 
 
 
 
 But i'm getting this error all the time:
  
 Warning: unexpected regex error (14) in c:\program files\apache
 group\apache\htdocs\eztatic\poll.php on line 25
 
 25: list(q1,q2,q3,q4,q5)= split (|, $answer, 5);
 
 
 Could any help
 
 Thank you very much in advance
 
 


-- 
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]