Discussions















                                          
User   Password   remember     (register)  ?

How to remove accents in PHP ?


Back to programming.


thibault    (2009-04-04)

thibault

 
How to remove accents in PHP ?

Here is a nice function that can help you to remove every accent in a text. It can be useful to build a url that works on a server running an old PHP version or to convert a text from UTF-8 to ISO-8859-1 format.

function replace_accents($string)
{
  return str_replace( array('à','á','â','ã','ä', 'ç', 'è','é','ê','ë', 'ì','í','î','ï', 'ñ', 'ò','ó','ô','õ','ö', 'ù','ú','û','ü', 'ý','ÿ', 'À','Á','Â','Ã','Ä', 'Ç', 'È','É','Ê','Ë', 'Ì','Í','Î','Ï', 'Ñ', 'Ò','Ó','Ô','Õ','Ö', 'Ù','Ú','Û','Ü', 'Ý'), array('a','a','a','a','a', 'c', 'e','e','e','e', 'i','i','i','i', 'n', 'o','o','o','o','o', 'u','u','u','u', 'y','y', 'A','A','A','A','A', 'C', 'E','E','E','E', 'I','I','I','I', 'N', 'O','O','O','O','O', 'U','U','U','U', 'Y'), $string);
}


By the way, as UTF-8 should be the most used format in the future, it is strongly recommanded to code all your pages in this format.


guest-91e551    (2009-09-15 18:40:01)
Let iconv handle it

<?php
// This covers all unicode characters
$text = iconv('UTF-8', 'US-ASCII//TRANSLIT', $text);
?>

Iconv manual at php.net:
http://us2.php.net/manual/en/function.iconv.php


ficgs
Suggestions

 Deleting accents with PHP - The solution
en.kioskea.net/faq/sujet-1005-deleting-accents-with-php

 Remove accents from a string with PHP - PHP tips & trick, misc.
webxadmin.free.fr/article/remove-accents-from-string-with-php-284.php

 Reading and removing accent characters : accent, charcters
www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_2088

 FAQTs - Knowledge Base - View Entry - How do I remove all accent from a string ?
www.faqts.com/knowledge_base/view.phtml/aid/32273/fid/1

 b2evolution :: View topic - Remove accents in pings
forums.b2evolution.net/viewtopic.php?t=5192

 Remove Letter Accents from Text | PHP Text Processing | Hot Scripts
www.hotscripts.com/listing/remove-letter-accents-from-text/



ficgs
More suggestions

This is a collaborative page, you may change the order of these suggestions by registering, then clicking the icons before the titles.


 scriptingBlog.com » Blog Archive » Remove Letter Accents from Text
www.scriptingblog.com/php-and-mysql/remove-letter-accents-from-text/39

 Function Reference/remove accents « WordPress Codex
codex.wordpress.org/Function_Reference/remove_accents

 web developer notes: remove accents from strings using postgresql
web-dev-tip.blogspot.com/2007/02/remove-accents-from-strings-using.html

 Download Removing accents in NET 2.0 - Removing accents in NET 2.0 - Removing accents in NET 2.0 with C# - Softpedia
webscripts.softpedia.com/script/Snippets/Removing-accents-in-NET-2-0-26394.

 Removing Accents In a Ruby String - Techniconseils
www.techniconseils.ca/en/scripts-remove-accents-ruby.php

 Remove Letter Accents from Text : PHP Scripts and Programs Miscellaneous Scripts Directory
www.advancescripts.com/detailed/16860.html

 Re: Problem when removing accents from a String :: ASPN Mail Archive :: ruby-talk
aspn.activestate.com/ASPN/Mail/Message/ruby-talk/3709919

  Removing accents and whitespace from files - WebDeveloper.com
www.webdeveloper.com/forum/showthread.php?t=92690

  Remove accents - Spring for .NET Community Forums
forum.springframework.net/showthread.php?t=1071

 Function for removing Accents?
www.velocityreviews.com/forums/t293027-function-for-removing-accents.html

  How to remove accents (A-Umlaut to A) - bytes
bytes.com/groups/net/689193-how-remove-accents-umlaut

 Source PHP - Chaine de caractères - Remove Accents
www.comscripts.com/sources/php.remove-accents.4.html

 Remove accents sql section at Free Download Manager
www.freedownloadmanager.org/downloads/remove_accents_sql_info/

  [wp-svn] [4050] trunk/wp-includes/formatting.php: Faster remove accents.
comox.textdrive.com/pipermail/wp-svn/2006-July/001685.html

 [#CRM-1439] Google geocode error when processing accented characters - CiviCRM Issue Tracker
issues.civicrm.org/jira/browse/CRM-1439

 Epsilon Clue » Blog Archive » Removing Accents in Strings
www.ooblick.com/weblog/2007/01/28/removing-accents-in-strings/

  Remove the french canadian accents - Zen Cart Support
www.zen-cart.com/forum/showthread.php?t=34989

 Snippets Tagged 'Accents'
snipplr.com/all/tags/accents/

  remove accents and symbols with sed - Shell Programming and Scripting - The UNIX and Linux Forums
www.unix.com/shell-programming-scripting/95859-remove-accents-symbols-sed.h

  Remove diacritical / accent marks from text? - The macosxhints Forums
forums.macosxhints.com/showthread.php?t=31622

 Forms - php and displaying French accents-how to amend the DWCS3 CSS, Ajax book tutorial? - Topic Powered by Infopop
friendsofed.infopop.net/4/OpenTopic?a=tpc&s=989094322&f=5283032876&

  Use Normalizer to Remove Accents : Normalizer « I18N « Java Tutorial
www.java2s.com/Tutorial/Java/0220__I18N/UseNormalizertoRemoveAccents.htm

 Warning: strtr() [function.strtr]: The second argument is not an array in /home/aptana/domains/forums.aptanacloud.com/web/htdocs/includes/session.php...
forums.aptana.com/viewtopic.php?f=20&t=8234



Response  
  Smilies

Guest name   (optional)       Register for more options.



Trackbacks : If you talked about this article in your blog or website, you may instantly get a backlink 
  There's no trackback at the moment.









 

FICGS message




Discussions



 


Q / A : You may write any question (and answer) in 10 languages :


 

Buttons: Facebook, Twitter, MySpace, Google, Technorati, Yahoo buzz... Ficgs Facebook Myspace Twitter Google Technorati Stumble upon Delicious Digg Yahoo buzz Wikio Furl Reddit Linkedin Squidoo Newsvine Yahoo My Web Blogmarks Comments Blinklist Email

You comment I follow : Links included in comments will be "dofollow" if your post is not an obvious spam, comments are published instantly.


Write upside down to your contacts !
(works with Facebook, Twitter, MSN, Yahoo, MySpace, Hi5, Bebo, Youtube...)






Tip of the day :

Do you know how to find a file to download on Rapidshare or Megaupload ?

Just try this Google query : site:www.rapidshare.com keywords

This is also a convenient way to find a page on Wikipedia or a particular link on a P2P torrent website.



FICGS is also a Free Internet Correspondence Games Server.

Here you can play Chess, Go & Poker Texas Holdem online for free in rated class tournaments and a unique world championship.

Free Internet Chess & Go Server


Feel free to link to FICGS :