Hi,
I have created an array with symbols that I'd like to allow in a string of text.
$symbols[] = '>'; // Greater Than or Open Angle Bracket
$symbols[] = '<'; // Less Than or Close Angle Bracket
$symbols[] = '/'; // Forward Slash
$symbols[] = '\\'; // Back Slash
$symbols[] = '&'; // Ampersand
$symbols[] = '£'; // Pound Sterling
$symbols[] = '$'; // Dollar
$symbols[] = '\"'; // Quotation Marks
$symbols[] = '\''; // Apostrophe
$symbols[] = '#'; // Hash
$symbols[] = ' '; // Space
$symbols[] = '.'; // Period
I would now like to use something like str_replace or preg_replace (whichever is best) to replace any character that is not included within the array $symbols with "".
I know there are other ways to filter characters but it isn't a suitable solution considering who will be maintaining it... :-\
I'm hoping for something like; but obviously a working way.
$myText = str_replace(!$symbols, "", $myText;
$myText = preg_replace(!$symbols, "", $myText;
Thank you for your help.