0

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;

}
?>
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by darkagn
1

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;
}
Votes + Comments
Great Coder!
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.