note 29064 deleted from function.preg-replace-callback by sniper

From: Date: Tue, 30 Sep 2003 12:26:16 +0000
Subject: note 29064 deleted from function.preg-replace-callback by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-57454@lists.php.net to get a copy of this message
Note Submitter: joao (_AT_) fischer.med.br ---- Wonder how to replace accented letters with 7bit characters like: água => agua cão => cao "All these character with accents are in the range of (hex) C0 to FF. They have an HTML entity like &eacute, where the second character is always the character without the accent. So we can replace each of these characters with the second character in the HTML entity" Here's what I got: function replace( $matches ) { $text = htmlentities( $matches[0] ); return $text[1]; } $string = 'água'; $string = preg_replace_callback( '/[\\xc0-\\xff]/', replace, $string ); echo $string; Thanks to Harry: http://forums.devshed.com/archive/5/2002/07/4/39944 João Paulo M. Fischer http://www.redemedica.com.br

« previous php.notes (#57454) next »