I am making an RSS parser that takes multiple XML inputs in to an
array and then sorts them by their date value... and it 'almost'
works... I always lose the top value of the second rss feed to be
parsed... its pretty annoying as this is often the most recently
updated RSS item that is missing from my multi-feed...
Help me please:
Currently, I am doing this:
usort($xmlreader_parsed_data, "rss_cmp");
which calls this function:
function rss_cmp($a, $b)
{
$a = strtotime($a->date);
$b = strtotime($b->date);
if ($a == $b) {
return 0;
}
return ($a $b) ? -1 : 1;
} 4 2099
UPDATE: I just added the following to the rss_cmp function, and it
seems to have worked... is it ok? Or will I regret this somewhere?
if (!$a) { return -1; }
if (!$b) { return 1; }
Seems to be a typo, comparison should be $a < $b.
I would make sure error_reporting(E_ALL) is on to see if that gives
any hints.
On Aug 15, 12:08 am, junkmate <junkm...@gmail.comwrote:
I am making an RSS parser that takes multiple XML inputs in to an
array and then sorts them by their date value... and it 'almost'
works... I always lose the top value of the second rss feed to be
parsed... its pretty annoying as this is often the most recently
updated RSS item that is missing from my multi-feed...
Help me please:
Currently, I am doing this:
usort($xmlreader_parsed_data, "rss_cmp");
which calls this function:
function rss_cmp($a, $b)
{
$a = strtotime($a->date);
$b = strtotime($b->date);
if ($a == $b) {
return 0;
}
return ($a $b) ? -1 : 1;
}
putting the coparison that way gives me results the wrong way around.
I want the latest date at the top (ie. the smallest) and to do that I
have to use - shouldnt cause a problem though right?
On Aug 17, 2:10 am, petersprc <peters...@gmail.comwrote:
Seems to be a typo, comparison should be $a < $b.
I would make sure error_reporting(E_ALL) is on to see if that gives
any hints.
On Aug 15, 12:08 am, junkmate <junkm...@gmail.comwrote:
I am making an RSS parser that takes multiple XML inputs in to an
array and then sorts them by their date value... and it 'almost'
works... I always lose the top value of the second rss feed to be
parsed... its pretty annoying as this is often the most recently
updated RSS item that is missing from my multi-feed...
Help me please:
Currently, I am doing this:
usort($xmlreader_parsed_data, "rss_cmp");
which calls this function:
function rss_cmp($a, $b)
{
$a = strtotime($a->date);
$b = strtotime($b->date);
if ($a == $b) {
return 0;
}
return ($a $b) ? -1 : 1;
}
Yes you're definitely right. I thought that might the cause of the
unexpected results. Not sure why data would go missing. I would see if
any warnings are triggered or I guess strtotime could also fail.
On Aug 16, 10:22 pm, junkmate <junkm...@gmail.comwrote:
putting the coparison that way gives me results the wrong way around.
I want the latest date at the top (ie. the smallest) and to do that I
have to use - shouldnt cause a problem though right?
On Aug 17, 2:10 am, petersprc <peters...@gmail.comwrote:
Seems to be a typo, comparison should be $a < $b.
I would make sure error_reporting(E_ALL) is on to see if that gives
any hints.
On Aug 15, 12:08 am, junkmate <junkm...@gmail.comwrote:
I am making an RSS parser that takes multiple XML inputs in to an
array and then sorts them by their date value... and it 'almost'
works... I always lose the top value of the second rss feed to be
parsed... its pretty annoying as this is often the most recently
updated RSS item that is missing from my multi-feed...
Help me please:
Currently, I am doing this:
usort($xmlreader_parsed_data, "rss_cmp");
which calls this function:
function rss_cmp($a, $b)
{
$a = strtotime($a->date);
$b = strtotime($b->date);
if ($a == $b) {
return 0;
}
return ($a $b) ? -1 : 1;
}
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mike |
last post by:
If I had a date in the format "01-Jan-05" it does not sort properly
with my sort routine:
function compareDate(a,b)
{
var date_a = new Date(a);
var date_b = new Date(b);
if (date_a < date_b)...
|
by: nidhog |
last post by:
Hello guys,
I made a script that extracts strings from a binary file. It works.
My next problem is sorting those strings.
Output is like:
---- snip ----
200501221530
|
by: Scott |
last post by:
I have a collection where the items in the collection are dates. I want to
iterate over the collection and build a value list string for the rowsource
of a listbox. The dates in the collection are...
|
by: Brian Henry |
last post by:
Here is another virtual mode example for the .NET 2.0 framework while
working with the list view. Since you can not access the items collection of
the list view you need to do sorting another...
|
by: Kamal |
last post by:
Hello all,
I have a very simple html table with collapsible rows and sorting
capabilities. The collapsible row is hidden with css rule
(display:none). When one clicks in the left of the...
| |
by: Don |
last post by:
I'm using Access 2000. My database collects lots and lots of data. One
aspect of that is to collect dimensional data from multiple checks during
the day. The way I've done that is to have a...
|
by: =?Utf-8?B?R2VyaGFyZA==?= |
last post by:
I have a vb.net 2.0 app that is loading a GridView with a DataSource that is
returned from a function.
The definitions in the function are:
Dim ReportDS As DataSet = New DataSet
Dim...
|
by: KevinADC |
last post by:
If you are entirely unfamiliar with using Perl to sort data, read the "Sorting Data with Perl - Part One and Two" articles before reading this article. Beginning Perl coders may find this article...
|
by: jrod11 |
last post by:
hi,
I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |