Hi, I need a function to replace anything that is not "alphanumeric" to a _ sign in a string. $str= "this is my text!"; output can be: "This_is_my_text_"; Please give me a function to do this... Thanks
I don't know if it's 100% reliable, but you could try this: $str= "this is my text!"; $result = preg_replace('/[^A-Za-z0-9]/', "_", $str); echo $result; PHP: