Is there any nice way to split an string on a space or a dot?
Like
$string = "test.test"
//result = test
$string = "test doe"
//result = test
Sure I can use explode two times, but I am sure that's not the best solutions ;)
If you want to split on several different chars, take a look at preg_split
//split string on space or period:
$split=preg_split('/[ \.]/', $string);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With