Aleksandar Aleksandar - 1 year ago 125
PHP Question

Removing special characters php

I need to remove special characters and white space form $data.
I tried trim and preg_replace without success...

$data = 'ello€ Wo@r"ldČ2';

$remove = ' ~"#$%&()=?+-@][€Ł|/');,:/ ';

Final data need to be like that elloWorldC2

Answer Source

removes all special charecters preg_replace('/[^a-zA-Z0-9]/s', '', $data);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download