Only allow English characters/letters/numbers and a few special characters

<>

This question already has an answer here:

Answers


You may create an array of allowed characters and then filter those that are not allowed:

$allowed = array_merge(range('a', 'z'), range('A', 'Z'), range(0, 9), array(' ', '+', '/', '-', '*', '.')); // Create an array of allowed characters

$string = 'This is allowed and this not é Ó ½ and nothing 123.'; // test string

$array = str_split($string); // split the string (character length = 1)

echo implode('', array_intersect($array, $allowed)); // Filter and implode !

Online demo.


Need Your Help

C# random value from dictionary and tuple

c# random dictionary tuples

I have the following code, and need to get a random item that contains the string "Region_1" from the dictionary.

How to make Navigation links responsive to browser resize

css layout website responsive-design media-queries

I am trying to make a website I am developing responsive, so far the elements that I want to make responsive to change in the the browser window are working well, except for the navigation text siz...

Highlighting Links

java swing hyperlink highlighting

I am creating a Help System that uses links (a JButton extension) that expand and collapse subpanels with JLabels in them. The links and the collapsible panels work, but I'm having trouble implemen...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.