The illegal characters in file names

231 views Asked by At

Image names in the '?' I can not change the character with the PHP rename function. str_replace function did not work either.

What is the solution?

sample pictures enter image description here

I used functions;

function replace($title){ 

    $text = trim($title);
    $search = array('Ç','ç','Ğ','ğ','ı','İ','Ö','ö','Ş','ş','Ü','ü',' ','%','?');
    $replace = array('c','c','g','g','i','i','o','o','s','s','u','u','_','_','-');
    $new_text = str_replace($search,$replace,$text);
    $value = preg_replace("@[^A-Za-z0-9-_]+@i","",$new_text);

    return $value;
}

I tried the iconv function, but it was illegal character error.

1

There are 1 answers

0
Mansoor H On

Your function working correctly, when i call your function like this echo replace("MaÇsoÖ");