Hello,

I am retrieving results from a RSS feed, but not all results have a title. I would like to run something like the below code which, lets me know how many times a title is empty.

If three "titles" are empty, then X code would dynamically echo "3" etc....

Not sure if a foreach would work... Thanks in advance!

<?php
if(empty($title)){
//Code for displaying how many times "$title" is empty

} else {

echo $title;

}
?>

So is $title the title of a single RSS feed item? If so, you can do something like:

$count = 0;
foreach($rssFeedItems as $title)
{
   if(empty($title))
      echo ++$count; // a prepend increment will add one to $count before it is used
   else
      echo $title;
}
commented: Great Coder! +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.