I need this string: "test1 test2-test3\test4" to be split into 4 strings:
Array
(
[0] => test1
[1] => test2
[2] => test3
[3] => test4
)
What am I doing wrong?
I've tried this:
<?php
$aa = 'test1 test2-test3\test4';
$arr = preg_split('#[\s|\|-]+#u', $aa);
print_r($arr);
?>
Array
(
[0] => test1
[1] => test2
[2] => test3\test4
)
And this:
<?php
$aa = 'test1 test2-test3\test4';
$arr = preg_split('#[\s|\\|-]+#u', $aa);
print_r($arr);
?>
Array
(
[0] => test1
[1] => test2
[2] => test3\test4
)
To no avail. For some reason it doesn't split by backslash- why?