I\'d like to use any php function or whatever so that i can remove any HTML code and special characters and gives me only alpha-numeric output
$des = "He
In a more detailed manner from Above example, Considering below is your string:
$string = '<div>This..</div> <a>is<a/> <strong>hello</strong> <i>world</i> ! هذا هو مرحبا العالم! !@#$%^&&**(*)<>?:";p[]"/.,\|`~1@#$%^&^&*(()908978867564564534423412313`1`` "Arabic Text نص عربي test 123 و,.m,............ ~~~ ٍ،]ٍْ}~ِ]ٍ}"; ';
Code:
echo preg_replace('/[^A-Za-z0-9 !@#$%^&*().]/u','', strip_tags($string));
Allows:
English letters (Capital and small), 0 to 9 and characters !@#$%^&*().
Removes:
All html tags, and special characters other than above
to allow periods and any other character just add them like so:
change: '#[^a-zA-Z ]#
'
to:'#[^a-zA-Z .()!]#
'
Remove all special character don't give space write in single line
trim(preg_replace('/ +/', ' ', preg_replace('/[^A-Za-z0-9 ]/', ' ',
urldecode(html_entity_decode(strip_tags($string))))));