This question already has an answer here:
In yii2, I would like to check for filename.
If this filename consist of any symbol (.$%-)
, replace it with _
.
Can you suggest some solutions for this?
</div>
This question already has an answer here:
In yii2, I would like to check for filename.
If this filename consist of any symbol (.$%-)
, replace it with _
.
Can you suggest some solutions for this?
</div>
Use regular expression search and replace:
//Perform a regular expression match first
if(preg_match('/[.$%-]+/', $file_name) == 1)
{
//perform regular expression search and replace
$new_name = preg_replace('/[.$%-]+/', '_', $file_name);
}