How to make a regular expression?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
11 views
Hello.

The output variable will receive a string with this value = "admin@mail.ru 100 5".
How to enter these data individually into an array, where the space is a separator?

Thanks in advance.
by | 11 views

3 Answers

0 like 0 dislike
It would be possible to use a simple explode, but the whole kitchen breaks, when they come to the line with double space.
It is better to use preg_split, but not as twobomb (as he showed you can do explode), and so:
$arr = preg_split("/[\\s]{1,}/",$str);
by
0 like 0 dislike
by
0 like 0 dislike
php.net/manual/ru/function.explode.php
$arr = explode(" ", $str);
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,456 users