PHP Issue :: preg_split instead of explode function

If the need is to parse a string and extract the words. Then its advisable to use preg_split instead of using the explode function.

Code follows :
preg_split ("/\s+/",$textInput);
where the first argument is the regular expression for finding one or more spaces and the second argument is the input text.

This option works far better than the explode(" ", $textInput).

Comments

Popular posts from this blog

Linux Newbie : Why grep almost never yields something productive

Linux Newbie : Why I cannot use Latex like those gurus?

Twofolds Joy of using Ubuntu