我需要从字符串中删除所有字符,然后再在字符串中出现此字符:
"www/audio"
不知道我该怎么做。
Answers:
考虑中
$string="We have www/audio path where the audio files are stored"; //Considering the string like this
您可以使用
strstr($string, 'www/audio');
要么
$expStr=explode("www/audio",$string);
$resultString="www/audio".$expStr[1];
我用这个功能
function strright($str, $separator) {
if (intval($separator)) {
return substr($str, -$separator);
} elseif ($separator === 0) {
return $str;
} else {
$strpos = strpos($str, $separator);
if ($strpos === false) {
return $str;
} else {
return substr($str, -$strpos + 1);
}
}
}
function strleft($str, $separator) {
if (intval($separator)) {
return substr($str, 0, $separator);
} elseif ($separator === 0) {
return $str;
} else {
$strpos = strpos($str, $separator);
if ($strpos === false) {
return $str;
} else {
return substr($str, 0, $strpos);
}
}
}
s($str)->afterFirst('www/audio')或s($str)->afterLast('www/audio')有所帮助,如在此独立库中找到的那样。