Hello, I want to cut the my variable for keywords . Here is my code : $replace = array('([\40])','([^a-zA-Z0-9-0-9a-zA-ÿ³¿¸])','(-{2,})'); $with = array('-','','-'); $filenameurl = preg_replace($replace,$with,$variable); Code (markup): This code edit the variable with "-" I wanna to be ", " instead "-" Thanks in advance and sorry for my bad english .
So basically you're trying to match and replace '([\40])' -> "-" '([^a-zA-Z0-9-0-9a-zA-ÿ³¿¸])' -> ", " This will basically replace any characters with a , '(-{2,})' -> "-" You realize the array is seperate matches right? Because if all you want to do is find \40 and replace it with ", ", then you don't even need to use an array, you could simply do preg_replace('([\40])', ", ", $variable); Otherwise this might be less processor intensive: $filanemurl = str_replace("-", ", ", $variable);