Hello All,
I want to change image names on below conditions
- All non word characters turns into space and
- then all spaces turns into
-
means if my image name is : Hello My name is'Kh@n "Mr. .Khan "
then it should be changed into Hello-My-name-is-kh-n-mr-Khan
.
i need to use below in two steps,
$old_name =' Hello My name is\'Kh@n "Mr. Khan ';
$space_name = preg_replace('/\W/',' ', $old_name);
$new_name= preg_replace('/\s+/','-', $space_name);
echo $new_name // returns Hello-My-name-is-kh-n-mr-Khan
is there any way to apply both conditions in single step??