shachar058 wrote on Sunday, November 06, 2016:
Hi all,
The ‘basename’ php method is used all over the project inorder to get the filename from a given path. The problem with this is, that if the filename is in non-english (e.g. hebrew) letters, the method erases these letters and returns empty. My solution for this was substituting this standard method with a customized method:
function basename_nonenglish($path){
$parts = preg_split(’~[\\/]~’, $path);
foreach ($parts as $key => $value){
$encoded = urlencode($value);
$parts[$key] = $encoded;
}
$encoded_path = implode("/", $parts);
$encoded_file_name = basename($encoded_path);
$decoded_file_name = urldecode($encoded_file_name);
return $decoded_file_name;
}
What are your thoughts on this?
Thanks,
shachar