Preg match?


Take a look at the following page:

If you look at the middle 3 boxes, the “Latest news” box. You will see a scrolling blog list of items. I use the following code to do it:

<?$xml = simplexml_load_file('');?>

<? strlen($xml->entry->title) > 60 ? $newsTitle = substr($xml->entry->title, 0, 60).'...' : $newsTitle = $xml->entry->title?>

                <?foreach($xml->entry as $entry):?>
                    <?foreach($entry->children() as $child):
                            if($child->getName() == 'link'):
                                    $link = $child['href'];
                    <?if($i < 11):?>
                        <div id="recent<?=$i?>"  style="<?=$i > 2 ? 'display:none;' : 'display:block;'?> border-bottom:1px dotted black; clear:both; width:250px;">
                            <p style="margin:13px 0;"><a style="font-size:10px;" href="<?=$link?>" target="_blank"><?=$entry->title?></a></p>
                            <p style="margin:5px 0;"><a style="font-size:10px;" href="<?=$link?>" target="_blank">
                            strip_tags(substr($entry->content, 0, 100));

Now the problem is that i need to also pull out the content of each feed. So i do something like this:

strip_tags(substr($entry->content, 0, 100));

And echo that out, it also pulls out the images. So i need to check to see if $entry->content contains an image and if so, not display it and only display the text…

Is this possible?


Of course! :wink:

I did this:

$text = strip_tags($entry->content);
$content = substr($text, 0, 80);

echo $content;

Thanks :stuck_out_tongue:

Surely you just need to apply striptags before substr’ing the content, no?