Basically I have this string
$str="word1 word2 word3";
I need
array(
'word1',
'word2',
'word3'
);
I made this function:
function explodeStrict($delimiter,$string) {
return preg_split("/{$delimiter}/",$string,null,PREG_SPLIT_NO_EMPTY);
}
But I need it to be fast. And this function is 2x slower than a simple explode();
(within a 1mil loop)
I have tried a vanilla style parsing each chars but it gets 7x slower than the explode();
Can you imagine a function as fast as explode that ignores empty elements?
With my function a 1milion loop takes 3.9 sec. Explode take 2 sec
Thanks