0

Possible Duplicate:
PHP remove accents

The title says most of it, but anyways...

I am getting data from an input file and inside the data we will have the character é. For our purposes we want to convert that to a regular lower case e.

Does anyone know how to do that?

Community
  • 1
  • 1
Josh Pennington
  • 6,418
  • 13
  • 60
  • 93
  • This is called [transliteration](http://en.wikipedia.org/wiki/Transliteration). – Gumbo Nov 08 '10 at 16:21
  • Not an exact duplicate of the 3542717. OP isn't asking how to replace all accents. – webbiedave Nov 08 '10 at 16:22
  • @webbiedave: I think this is just a simplification of what he is actually doing. But I’m willing to reopen the question if I am wrong. – Gumbo Nov 08 '10 at 16:27
  • Do you just want to replace this single character or are you looking for a way to transliterate a text? – Gumbo Nov 08 '10 at 16:27
  • @Gumbo: It very well could be. Just wanted to point out that the closers have gone ahead and assumed what the OP desired. Either way, this is no doubt many dups of *other* search and replace questions out there and there are ample answers below so I think reopening is moot :) – webbiedave Nov 08 '10 at 16:31

4 Answers4

2

I'd use this:

PHP Function: string strtr ( string $str , string $from , string $to )

from the PHP Site:

<?php
//In this form, strtr() does byte-by-byte translation
//Therefore, we are assuming a single-byte encoding here:
$addr = strtr($addr, "äåö", "aao");
?>
Les
  • 2,316
  • 16
  • 17
1

Just that one character? This seems too obvious... just replace it.

$str = "é";

$str = str_replace("é","e",$str);

echo $str;  // "e"
Fosco
  • 38,138
  • 7
  • 87
  • 101
  • While this is correct it turns out that my problem was that in my input this é ended up not actually being recognized as an é, but something else completely. I tried your code and it did work (last time I trust what someone else said did not work). – Josh Pennington Nov 12 '10 at 12:55
0

http://php.net/manual/en/function.str-replace.php

$myText = str_replace( array('é'), array('e'), $myText);
Industrial
  • 41,400
  • 69
  • 194
  • 289
0

$string = str_replace('é','e',$string);

Stewie
  • 3,103
  • 2
  • 24
  • 22