Jump to content

how to use str_replace and htmlentities


andz

Recommended Posts

@thebadbad:

 

i tried applying that solution but there's an affected script and wont work... but when i tried applying str_replace it's working...

 

so i thought that i can apply htmlentities inside str_replace but i don't know how to do it.

 

 

but there's an affected script and wont work

 

Huh? Do you mean that you only want to convert certain characters, like < and >? Using str_replace():

 

<?php
$val = str_replace('<', '<', $val);
$val = str_replace('>', '>', $val);
?>

If that's not what you want, please explain your problem better.

Well, htmlentities() converts all applicable characters. What went wrong when using htmlentities()? If you've got a set of characters you want to convert, just run them through str_replace():

 

<?php
$replace = array(
'<' => '<',
'>' => '>',
'"' => '"'
//...
);
$str = str_replace(array_keys($replace), $replace, $str);
?>

not using it because i'm just using a ready made script and when using htmlentities() it cause a problem on xajax.

 

but when i applied str_replace() the problem didn't occured.

 

just finding a solution to convert all of the html entity into their respective value and put it in str_replace() just like THEBADBAD solution.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.