Created
December 12, 2014 20:54
-
-
Save devluis/eed79da548c2406097d9 to your computer and use it in GitHub Desktop.
Replace special chars in php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$stringOriginal = "Este string contiene acentos, ÁFRICA, MÉXICO, ÍNDICE, CANCIÓN y NÚMERO."; | |
$specialChars = array("á", "é", "í", "ó", "ú", "Á", "É", "Í", "Ó", "Ú", "ñ", "Ñ"); | |
$replacementChars = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U", "n", "N"); | |
$replacedString = str_replace($specialChars, $replacementChars, $originalString); | |
print $replacedString; // output 'Este string contiene acentos, ÁFRICA, MÉXICO, ÍNDICE, CANCIÓN y NÚMERO.' | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment