Jump to content

Recommended Posts

Hey everyone!

I'm trying to figure out how to build a function to REPLACE non-standard chars in a HTML string such as

É	É
Ê	Ê
Í	Í
Ó	Ó
Ô	Ô

 

something like

function AnsiChars($htm_string){
...
return <<html with special char codes replaced>>
}

 

http://www.php.net/chr

The problem is how do I get the char number to replace it

try pressing ALT+0199 in your keyboard and you get what i mean.

 

I appreciate any help!

Link to comment
https://forums.phpfreaks.com/topic/51135-php-function-%C3%A7-%C3%A7/
Share on other sites

If you wanr to be more selective than htmlentities, you could use strtr()

 

<?php
$ansi = array(
    'É'	=> 'É' ,
    'Ê'	=> 'Ê' ,
    'Í'	=> 'Í' ,
    'Ó'	=> 'Ó' ,
    'Ô'	=> 'Ô'
);

$txt = 'RECIPÉ RÓLE';

echo strtr($txt, $ansi)
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.