I have a string. I want to write a script in PHP for return a string if it has specific characters.
For example: "Hi, this is the sample.png" is a string. Now I want to output as "Hi, this is the".
I.e., if the string contains .jpg, .png, then I need to replace those words from a string.
This is my sample code:
$output = preg_replace('/.png/', '$1','Hi, this is the sample.png');
print_r($output);exit;