PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
digitalnap
Forum Newbie
Posts: 4 Joined: Sat Jun 18, 2005 11:27 am
Post
by digitalnap » Sat Jun 18, 2005 11:38 am
Hi. I am pulling my del.icio.us links via an RSS feed with MagpieRSS and got that working fine. The problem is I want to sort my links alphabetically on my website. I tried using sort() but it will only sort by post date then alphabetically so what I end up with is sections of alphabatized links as opposed to one long list. What I need to do is ignore the post date and sort solely by title. I am not familiar enough with PHP to figure out a way around this so I was wondering if someone on this board could provide me with some insight. Here is my code:
Code: Select all
<ul id="links">
<?php
require_once "../../magpierss/rss_fetch.inc";
$yummy = fetch_rss("http://del.icio.us/rss/digitalnap/digitalnap");
$maxitems = 5000;
$yummyitems = array_slice($yummy->items, 0, $maxitems);
sort($yummyitems);
foreach ($yummyitems as $yummyitem) {
print '<li>';
print '<a href="';
print $yummyitem['link'];
print '" target="blank" title="';
print $yummyitem['title'];
print '">';
print $yummyitem['title'];
print '</a>';
if (isset($yummyitem['description'])) {
print '<br />';
print '';
print $yummyitem['description'];
}
print '</li>';
print "\n";
}
?>
</ul>
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Sat Jun 18, 2005 11:49 am
Put the following line of code before sort($yummyitems) and post what it says. So I can see what the array looks like now.
Code: Select all
echo '<HR><PRE>'; print_r($yummyitems); echo '</PRE>';
digitalnap
Forum Newbie
Posts: 4 Joined: Sat Jun 18, 2005 11:27 am
Post
by digitalnap » Sat Jun 18, 2005 11:55 am
Code: Select all
Array
(
ї0] => Array
(
їabout] => http://www.flickr.com/photos/990000/
їtitle] => Flickr/Red
їlink] => http://www.flickr.com/photos/990000/
їdescription] => Red's Flickr site
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-05-09T06:45:00Z
їsubject] => digitalnap favorites friends nyc photoblogs photography
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => Red's Flickr site
їdate_timestamp] => 1115621100
)
ї1] => Array
(
їabout] => http://www2.foxsearchlight.com/gardenstate/blog/
їtitle] => Zach Braff's Garden State Blog
їlink] => http://www2.foxsearchlight.com/gardenstate/blog/
їdescription] => Weblog of Zach Braff (from Scrubs and Garden State)
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-05-08T16:27:00Z
їsubject] => cinema digitalnap famous favorites weblogs
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => Weblog of Zach Braff (from Scrubs and Garden State)
їdate_timestamp] => 1115569620
)
ї2] => Array
(
їabout] => http://hooplahngiggles.com/
їtitle] => Hooplah and Giggles
їlink] => http://hooplahngiggles.com/
їdescription] => Missouri based weblog
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-04-30T17:36:00Z
їsubject] => digitalnap weblogs
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => Missouri based weblog
їdate_timestamp] => 1114882560
)
ї3] => Array
(
їabout] => http://wvs.topleftpixel.com/
їtitle] => Daily Dose of Imagery
їlink] => http://wvs.topleftpixel.com/
їdescription] => Photography by Toronto based Sam Javanrouh
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-04-30T03:47:00Z
їsubject] => canada digitalnap photoblogs photography
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => Photography by Toronto based Sam Javanrouh
їdate_timestamp] => 1114832820
)
ї4] => Array
(
їabout] => http://www.frankieboots.net/
їtitle] => Frankieboots
їlink] => http://www.frankieboots.net/
їdescription] => Photography of NYC based Michael Dominic
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-04-30T02:11:00Z
їsubject] => digitalnap nyc photoblogs photography
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => Photography of NYC based Michael Dominic
їdate_timestamp] => 1114827060
)
ї5] => Array
(
їabout] => http://alistapart.com/
їtitle] => A List Apart
їlink] => http://alistapart.com/
їdescription] => For people who make websites
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-04-25T07:45:00Z
їsubject] => design digitalnap digitalnap_design favorites resources web_design_resources web_standards
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => For people who make websites
їdate_timestamp] => 1114415100
)
ї6] => Array
(
їabout] => http://positive-negative.com/
їtitle] => Positive Negative
їlink] => http://positive-negative.com/
їdescription] => Photography of NYC based Frank Kolodziej
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-04-25T07:19:00Z
їsubject] => digitalnap favorites nyc photoblogs photography
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => Photography of NYC based Frank Kolodziej
їdate_timestamp] => 1114413540
)
ї7] => Array
(
їabout] => http://stopdesign.com/
їtitle] => Stopdesign
їlink] => http://stopdesign.com/
їdescription] => Design consultancy based in San Francisco, CA
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-04-25T07:13:00Z
їsubject] => design digitalnap favorites s web_design_resources web_standards weblogs
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => Design consultancy based in San Francisco, CA
їdate_timestamp] => 1114413180
)
ї8] => Array
(
їabout] => http://www.kottke.org/
їtitle] => Kottke
їlink] => http://www.kottke.org/
їdescription] => Home of fine hypertext products
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-01-07T21:05:00Z
їsubject] => digitalnap favorites nyc weblogs
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => Home of fine hypertext products
їdate_timestamp] => 1105131900
)
ї9] => Array
(
їabout] => http://www.990000.com/
їtitle] => 990000
їlink] => http://www.990000.com/
їdescription] => New Yory City photography
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-01-05T22:15:00Z
їsubject] => digitalnap favorites friends nyc photoblogs photography
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => New Yory City photography
їdate_timestamp] => 1104963300
)
ї10] => Array
(
їabout] => http://chicagouncommon.com/
їtitle] => Chicago Uncommon
їlink] => http://chicagouncommon.com/
їdescription] => Chicago Photos, Photographs, Pictures by Dawn Mikulich
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-01-05T22:06:00Z
їsubject] => chicago digitalnap favorites photoblogs photography
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => Chicago Photos, Photographs, Pictures by Dawn Mikulich
їdate_timestamp] => 1104962760
)
ї11] => Array
(
їabout] => http://www.absenter.org/
їtitle] => Absenter
їlink] => http://www.absenter.org/
їdescription] => Photographs, images, visuals from Chicago
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-01-05T22:06:00Z
їsubject] => chicago digitalnap favorites photoblogs photography
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => Photographs, images, visuals from Chicago
їdate_timestamp] => 1104962760
)
ї12] => Array
(
їabout] => http://www.toybird.org/
їtitle] => Toybird
їlink] => http://www.toybird.org/
їdescription] => Weblog of Chicago based Nazarin Hamid
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-01-05T22:02:00Z
їsubject] => chicago digitalnap favorites weblogs
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => Weblog of Chicago based Nazarin Hamid
їdate_timestamp] => 1104962520
)
ї13] => Array
(
їabout] => http://simplebits.com/
їtitle] => SimpleBits
їlink] => http://simplebits.com/
їdescription] => Hand-crafted web sites, pixels and text
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-01-05T20:57:00Z
їsubject] => design digitalnap favorites s web_design_resources web_standards weblogs
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => Hand-crafted web sites, pixels and text
їdate_timestamp] => 1104958620
)
ї14] => Array
(
їabout] => http://subinev.com/
їtitle] => Subinev
їlink] => http://subinev.com/
їdescription] => Bryan's words and photos and whatever else he feels the need to spew onto the internet.
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-01-05T20:54:00Z
їsubject] => digitalnap favorites friends nyc photoblogs photography s weblogs
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => Bryan's words and photos and whatever else he feels the need to spew onto the internet.
їdate_timestamp] => 1104958440
)
ї15] => Array
(
їabout] => http://rion.nu/
їtitle] => Rion
їlink] => http://rion.nu/
їdescription] => New York City street photography by Rion Nakaya
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-01-05T20:54:00Z
їsubject] => digitalnap favorites friends nyc photoblogs photography
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => New York City street photography by Rion Nakaya
їdate_timestamp] => 1104958440
)
ї16] => Array
(
їabout] => http://www.spreadfirefox.com/
їtitle] => Spread Firefox
їlink] => http://www.spreadfirefox.com/
їdescription] => Community site devoted to spreading the word about Firefox
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-01-05T20:47:00Z
їsubject] => communities digitalnap firefox s
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => Community site devoted to spreading the word about Firefox
їdate_timestamp] => 1104958020
)
ї17] => Array
(
їabout] => http://engadget.com/
їtitle] => Engadget
їlink] => http://engadget.com/
їdescription] => Web magazine about the world of gadgets and consumer electronics
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-01-05T19:04:00Z
їsubject] => digitalnap favorites technology weblogs
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => Web magazine about the world of gadgets and consumer electronics
їdate_timestamp] => 1104951840
)
ї18] => Array
(
їabout] => http://yewknee.com/
їtitle] => Yewknee
їlink] => http://yewknee.com/
їdescription] => Weblog of Michael Eades
їdc] => Array
(
їcreator] => digitalnap
їdate] => 2005-01-05T18:12:00Z
їsubject] => digitalnap favorites weblogs
)
їtaxo] => Array
(
їtopics] =>
їtopics_bag] =>
)
їtopics_bag] =>
їtopics] =>
їsummary] => Weblog of Michael Eades
їdate_timestamp] => 1104948720
)
)
digitalnap
Forum Newbie
Posts: 4 Joined: Sat Jun 18, 2005 11:27 am
Post
by digitalnap » Sat Jun 18, 2005 12:16 pm
I tried working with array_multisort but could not get anything to work. Can someone please help with implementing this? Thanks!
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Sat Jun 18, 2005 12:18 pm
No problem. Post what you've tried and we'll work through it.
digitalnap
Forum Newbie
Posts: 4 Joined: Sat Jun 18, 2005 11:27 am
Post
by digitalnap » Sat Jun 18, 2005 12:21 pm
Actually, I just got it!
This is what I used:
Code: Select all
function comparar($a, $b) {
return strnatcasecmp($a["title"], $b["title"]);
}
usort($yummyitems, "comparar");
Thanks for the help!