Reputation: 644
I need to replace only these 3 symbol for my XML:
&
<
>
I used htmlspecialchars but it will replace single and double quotes too.
Upvotes: 2
Views: 71
Reputation: 58
Have a look at the htmlspecialchars documentation. You can use flags to ignore quotes (you might be interested in the ENT_NOQUOTES flag).
Here's an example from the same article :
<?php
$str = "Jane & 'Tarzan'";
echo htmlspecialchars($str, ENT_COMPAT); // Will only convert double quotes
echo "<br>";
echo htmlspecialchars($str, ENT_QUOTES); // Converts double and single quotes
echo "<br>";
echo htmlspecialchars($str, ENT_NOQUOTES); // Does not convert any quotes
?>
Upvotes: 2