I'm trying to create a text editor. My basic code is if (($fp = file($fullPath)) !== FALSE) { for ($idx = 0; $idx < count($fp); ++$idx) { $contents[] = $fp[$idx]; } } <textarea name="contents" wrap="soft"><?php echo $contents; ?></textarea> Code (markup): The above works fine until I try it on a line like this: I need the output to exatcly match the line read but it only displays up to the closing tag like I've tried using htmlentities when the array is created, like below, but it still fails. $contents[] = htmlentities($fp[$idx]); Code (markup): If I echo the line as it is being added to the array, it shows it is being read correctly so the problem seems to be with how the textarea handles the code. Does anyone know how to code this so it displays correctly?
Thanks for the suggestion but since htmlspecialchars is just a subset of htmlentities, it fails the same way.
You shouldn't need to use anything. Text like: <p class="hdr">Some text here</p> should appear fine, even with the tags not encoded (I just tested it on IE/FF). There is something else wrong. Upload the script and show us a live link. Peace,
Yes, you are correct. It was my mistake. I was preparing a cut-down script that I could post here and realized the code was only reading in one line of text. It was working on some files because they didn't have line breaks in them. I changed the code to account for that and it is working correctly now. I appreciate both of you trying to help. Without it I probably would not have noticed this silly mistake.