How to remove all special char except $
(dollar sign) using php ?
I tried use this
$string = preg_replace("/[^ \w]+/", "", $string);
But all special char include $
(dollar sign) was remove
i tried this too $string = preg_replace("/$[^ \w]+/", "", $string);
But not work.
I want to store $
(dollar sign) , How can i do that ?
You're accepting so few characters that you could just "spell them out": everything that is not A-Z0-9$ -> replace.
<?php
$input= '_~!@#$%^&*()+ babnQWWWEWQEJ';
echo preg_replace('/[^A-Z0-9$]+/', '', $input);