I am retrieving text stored in a database, and I want to strip out any HTML tags and then only display the first 30 characters with "..." to show the user that there is more text to view.

My problem is with stripping out HTML tags, the code is stripping out the text enclosed within the HTML tags as well.

Here is the code I am using:

$pat = "<{1}.+>{1}";

if (ereg("text", $type)){ //if the field type is text look for HTML tags to remove
$content_array[$c] = ereg_replace($pat, '', $content_array[$c]);
$content_array[$c] = substr($content_array[$c], 1, 30);
$content_array[$c] = $content_array[$c]."...";

echo $content_array[$c];

What should the correct $pat be?



PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to