Search code examples
phpstringfilesubstringsubstr

How to get the part of string coming after first word and underscore from the given string in PHP?


Following is one variable that contains the string:

 $msg ='file_fafe9add9c26415689ffcfbc000d7751.docx';

I don't want initial part(i.e. file_) from the file name below. It should come as follows :

$msg ='fafe9add9c26415689ffcfbc000d7751.docx';

How could I achieve it in PHP in an efficient and best way?

Thanks in advance.


Solution

  • str_replace('file_', '', $msg)