ameisez Posted December 10, 2011 Share Posted December 10, 2011 I got this code to edit/save a specific text file online. <?phpif($_POST['Submit']){$open = fopen("b1.txt","w+");$text = $_POST['update'];fwrite($open, $text);fclose($open);echo "File updated.<br />";echo "File:<br />";$file = file("b1.txt");foreach($file as $text) {echo $text."<br />";}}else{$file = file("b1.txt");echo "<form action=\"".$PHP_SELF."\" method=\"post\">";echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">";foreach($file as $text) {echo $text;}echo "</textarea>";echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n</form>";}?> This works fine except when I input special character from ISO 8859-1 Characters. How can i make it save all special characters in "Entity Number Format" so that when it is read back it will show the special character? For example, when I enter Hello Günter it should be saved as Hello Günter Thanks Link to comment Share on other sites More sharing options...
Ingolme Posted December 10, 2011 Share Posted December 10, 2011 You can use the PHP htmlentities() function to convert every special character to an entity.You'll need to use the ENT_XML1 flag to ensure it uses numbers on all characters except < > & ' and " Link to comment Share on other sites More sharing options...
ameisez Posted December 11, 2011 Author Share Posted December 11, 2011 Hi, Thanks a lot for your reply. Seems like this is all I need. I will check it out tonight. Thanks again. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.