I am trying to get 2 words from a string, where the 2 words can be different each time.
In this example, I'm trying to get Open and On Hold
$str = 'Status Changed from Open to On Hold';
I've managed to get Open with this code:
$starting_word = 'Status Changed from';
$ending_word = 'to';
$subtring_start = strpos($str, $starting_word).strlen($starting_word);
$size = strpos($str, $ending_word, $subtring_start) - $subtring_start;
$a = substr($str, $subtring_start, $size);
And then I tried to get On Hold using this, but it's returning nothing.
$subtring_start = strpos($str, $a);
$size = strpos($str, '', $subtring_start) - $subtring_start;
$b = substr($str, $subtring_start, $size);
echo $b;