I am using PHP to manage a string of text coming out of a database.
But for some reason when I try and echo the string onto my page, the HTML code just comes through as text - so you can see the img src= and br tags.
The PHP code I'm using to manipulate the database output is basically to show only the first 180 words of the string.
Code: Select all
<small>Headline 1</small><br />
<b>Date: </b><br />
<br />
<?php
$maxlength = "180";
$newstext = addslashes("[Field: TEXT XHTML]");
$newstextnew = "";
$words = explode(" ", $newstext);
foreach ($words as $key => $word) {
if ($key < $maxlength) {
echo($word." ");
} elseif ($key == $maxlength) {
echo($word."...");
}
}
?>
<br /><br />
<hr />So I guess it must be something to do with the content-type of the string once PHP has done it's stuff.
There's nothing I can do on the database side of things to tell it text/html as the database I'm using is FileMaker Pro and the tag saying, [Field: TEXT XHTML] is a tag that gets replaced with FileMaker data, before it gets parsed by PHP.
I was wondering if there's a way to force a content type of text/html for the output of a string??
I don't really know much about mime types and content types - but I'm assuming this can only be done at the top of the page, in the headers.
Is there anyway I can tell the browser interpret each echo($word) as HTML?
Any ideas?
Thanks
Ben