Aleksandar Aleksandar - 2 months ago 17
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

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

Comments