I need a function that returns the substring between two words (or two characters).
I'm wondering whether there is a php function that achieves that. I do not want to think about regex (well, I could do one but really don't think it's the best way to go). Thinking of strpos
and substr
functions.
Here's an example:
$string = "foo I wanna a cake foo";
We call the function: $substring = getInnerSubstring($string,"foo");
It returns: " I wanna a cake ".
Update:
$string =" foo I like php foo, but foo I also like asp foo, foo I feel hero foo";
我得到一个像{"I like php", "I also like asp", "I feel hero"}
的array.