note 29064 added to function.preg-replace-callback

From: Date: Fri, 31 Jan 2003 20:44:07 +0000
Subject: note 29064 added to function.preg-replace-callback
Groups: php.notes 
Request: Send a blank email to php-notes+get-43220@lists.php.net to get a copy of this message
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 -- http://www.php.net/manual/en/function.preg-replace-callback.php http://master.php.net/manage/user-notes.php?action=edit+29064 http://master.php.net/manage/user-notes.php?action=delete+29064 http://master.php.net/manage/user-notes.php?action=reject+29064

« previous php.notes (#43220) next »