如何获得指定索引与其后的任何字符之间的子字符串?

时间:2019-07-03 16:46:38

标签: php

我有一个字符串,我想从起始索引中获取子字符串,直到指定的字符出现

string = "hellome@gmail.com"
Result Needed = "lome"

1 个答案:

答案 0 :(得分:0)

$str = "hellomyself@gmail.com"
$substr = substr($str,3,strpos($str,'@'))
//where `@` is specified character & 3 is specified index