kamal
kamal

Reputation: 1546

how to close open html tags automatically with php?

I developed many sites on php and mysql.
I have a problem on fetching certain words like i use

SELECT *,left('<field>',200) from < table >

I got the problem on layout of whole website due to no closing of opened tags.
any suggestion would be great.

I used strip_tags() and then substr() to crop text.
but i need a permanent solution.

update

<?php
$fragment = '<p>What a mighty fine <a href="blah">da';
$tidy = new tidy();
$tidy->parseString($fragment,array('show-body-only'=>true),'utf8');
$tidy->cleanRepair();
echo $tidy;
?>

enable php_tidy extension in localhost through php.ini and it works.

Upvotes: 2

Views: 3905

Answers (1)

kamal
kamal

Reputation: 1546

<?php
$fragment = '<p>What a mighty fine <a href="blah">da';
$tidy = new tidy();
$tidy->parseString($fragment,array('show-body-only'=>true),'utf8');
$tidy->cleanRepair();
echo $tidy;
?>

enable php_tidy extension in localhost through php.ini and it works.

Upvotes: 8

Related Questions