is there any nice way to split an string after \" \" or . ?
Like
$string = \"test.test\" result = test
$string = \"test doe\" result = test
<
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);
You want the strtok function. The manual gives this example:
<?php
$string = "This is\tan example\nstring";
/* Use tab and newline as tokenizing characters as well */
$tok = strtok($string, " \n\t");
while ($tok !== false) {
echo "Word=$tok<br />";
$tok = strtok(" \n\t");
}
?>
Though in your case I suspect that using explode
twice is easier and looks better.
You could do a strtr of . into space and then explode by space. Since strtr is very fast.
There's string token strtok.