[Solved] How to allow specific values in my string [duplicate]


You can use preg_replace to remove all special characters from your string.

Example

echo $text= str_replace(' ','|', preg_replace('/[^A-Za-z0-9 ]/', '',"This is some $123 Money"));

Output

This|is|some|123|Money

solved How to allow specific values in my string [duplicate]