Can anyone explain me this code split("[ ]+", $s);
thanks
$s = "Split this sentence by spaces";
$words = split("[ ]+", $s);
print_r($words);
Output:
Array
(
[0] => Split
[1] => this
[2] => sentence
[3] => by
[4] => spaces
)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Split string into array by regular expression. This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.
I reccommend ‘explode’ function instead ‘split’:
Output: