Reputation: 980
I've some html code
<p style="color:red;font-size:12px;">This economy car is great value for money and with the added benefit of air conditioning is ideal for couples and small families. A ?500 excess applies which can be waived to NIL for only <b>5.00</b> per day</p>
am using the following methods
substr($mytext,0,25);
and
$s = html_entity_decode($mytext);
$sub = substr($s, 0, 25);
But both of these are not working. 1st one returns an empty result and 2nd one returns the sting contains all the html codes..
Upvotes: 0
Views: 147
Reputation:
substr(strip_tags($mytext), 0, 25)
this wil show only first 25 characters with out displaying html
Upvotes: 0
Reputation: 15958
Make this:
echo (substr(strip_tags($mytext), 0, 25));
This strips all tags and shows you the first 25 chars of the given string.
Example: http://www.ideone.com/6TgJX
Upvotes: 3