Hello all, I am using curl function to get some pages on the web. I want to ignore the characters which is not in english. I want to get only english characters and all the punctuation marks. how can i do this with str replace? thanks
function remove_unwanted( $var ) { static $allowed_chars = '!"#$%&\'()*+,-.\\/0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; return preg_replace( '/[^' . $allowed_chars . ']/', '', $var ); } PHP:
Hello, this worked kind of. but There is no space between words. All the words came together and there is no line breaks as well. thanks
*sighs* <?php function remove_unwanted( $var ) { static $allowed_chars = "!\"#$%&'()*+,-.\\\\\\/0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ \n"; return preg_replace( '/[^' . $allowed_chars . ']/', '', $var ); } echo remove_unwanted('New<br />[]éépost' . "\n" . '<br>asdaéá'); // Example PHP: Returns: New<br />[]post <br>asda Code (markup):