PHP remove symbols from string PHP remove symbols from string php php

PHP remove symbols from string


The solution is this:$string = preg_replace('/[^\p{L}\p{N}\s]/u', '', $string);


$string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.echo $string; // output will be abcdef-g for 'a|"bc!@£de^&$f g'


Try this:

<?php$string = "Remove these characters: £äó";$string = preg_replace('/[^(\x20-\x7F)]*/','', $string);echo $string;?>