Jump to content

Making links, removing special chars


Rommeo

Recommended Posts

I m taking a text from user and I m using it as a link.

like ;

// My function 
$targetChars=array('<', '>', '\\');
$text=str_replace($targetChars, "+", $text);

user entered  : "my name is>Rommeo"

link : www.mysite.com/my+name+is+Rommeo

 

I need to remove the special chars. But today I have noticed that user can enter a char in his/her language or something like a comma, dot etc.

 

So simply, instead of removing special chars from the text that user entered, I just want to take letters that are in english alphabet, and when there is a whitespace I want to put there "+" sign. Cause otherwise, since I do not know what user will enter, It wont be usefull to write all chars and special chars into targetChars array that are not in english alphabet.

 

So can anyone tell me a way to do this ? Is there any special function for this purpose ?

Thanx in advance.

Link to comment
https://forums.phpfreaks.com/topic/184905-making-links-removing-special-chars/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.