在php中查找字符串中子字符串的最佳方法

i have a string lets say $str = 'welcome to my home';

from the above string how to find $substr = 'to my';

i can use substring function that is substr

substr($str,startposition , length);

i don't know the exact position of my substring, the above one i mentioned as a example. my substring may be in 1st position may be in middle position, may be in last position.

that can be doable by 3 steps

$position = strpos( 'welcome to my home' , 'to my');
$length = strlen('to my');
$mysubstr = substr($str,$position,$length);

but is there any optimized solution?

$position = strpos( 'welcome to my home' , 'to my');

The count starts from 0, so in the above example, $position will equal 8.