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($xmlreade r_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 2103
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($xmlreade r_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...@gmai l.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($xmlreade r_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...@gmai l.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($xmlreade r_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)
{ return -1; }
else
|
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 not in chronological order. Is
there a way to first sort the collection and put the dates in chronological
order before creating the value list string? Or, how would I iterate over
the collection pulling out the dates in chronological order?
...
|
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 way... here is my code on how I
did it to help anyone starting out get an idea of how to use virtual mode in
..NET 2.0
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
|
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 expandable row, the
hidden row is made visible with css. The problem is when i sort the
rows, the hidden rows get sorted as well which i don't want and want
to be moved (while sorting) relative to their parent rows. The
following is my complete html code...
| |
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 field for the date and then
multiple columns to enter the individual readings. When I go to query this
data the columns come up "left to right" or landscape if you think of it
that way. An example would be;
Reading One Reading Two Reading...
|
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 ReportTable As System.Data.DataTable = New
System.Data.DataTable("SendTo")
The ReportTable is populated row by row by data gotten back from the
|
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 uses unfamiliar terms and syntax. Intermediate and advanced Perl coders should find this article useful. The object of the article is to inform the reader, it is not about how to code Perl or how to write good Perl code, but to teach the Schwartzian...
|
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 there are, it crashes.
There are currently 6 columns, and I only want 4. How do I remove the last two (discount and date)?
Here is a link: http://www.jaredmoore.com/tablesorter/docs/salestable.html
Here is some jquery js that I think...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |