I need to remove all characters from any string before the occurrence of this inside the string:
"www/audio"
Not sure how I can do this.
You can use strstr to do this. Show activity on this post. The explode is in fact a better answer, as the question was about removing the text before the string.
substr() function: The substr() function is an inbuilt function in PHP is used to extract a specific part of string.
Using str_replace() Method: The str_replace() method is used to remove all the special characters from the given string str by replacing these characters with the white space (” “).
You can use strstr to do this.
echo strstr($str, 'www/audio');
Considering
$string="We have www/audio path where the audio files are stored"; //Considering the string like this
Either you can use
strstr($string, 'www/audio');
Or
$expStr=explode("www/audio",$string); $resultString="www/audio".$expStr[1];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With