PHP - Finding the correct occurrence order
I've a PHP string for example this string (haystack):
$text = "here is a sample: this text, and this will be exploded. this also
| this one too :)";
Now I would like to set a PHP array in a order where the needle occurs in
the string. So this is my needle:
$needle = array(",",".","|",":");
When searching for the needle in the $text string this should be the output:
Array (
[0] => :
[1] => ,
[2] => .
[3] => |
[4] => :
)
Is this possible to achieve in PHP?
This is similar to this question but that's for JavaScript.
No comments:
Post a Comment