| | |
Display Number of Times X Value is Empty
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Mar 2008
Posts: 36
Reputation:
Solved Threads: 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!
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 Syntax (Toggle Plain Text)
<?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:
php Syntax (Toggle Plain Text)
$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; }
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend. ![]() |
Similar Threads
- number of times to display steps (C++)
- number of times each number in array occurs? (C)
- display the number of capitals letters in the sentence (Assembly)
- Number of times a number appears in an array (C++)
Other Threads in the PHP Forum
- Previous Thread: problem to create input text continiously?
- Next Thread: sql syntax issue
| Thread Tools | Search this Thread |






