Solved

RSS Enclosures in PHP

Posted on 2006-10-26
3
1,729 Views
Last Modified: 2010-05-18
Trying to obtain the <enclosure> details for a podcasting page...  I've got the content displaying properly but I need to access the content inside the enclosure.

Outputting the item gives:

[enclosure] => Array
        (
            [url] => http://website/directory/name.mp3
            [length] => 4,374,069
            [type] => audio/mp3
        )

So I've got a "download this podcast" link but I can't get the [url] element from the enclosure... what is the syntax for doing this?  Because it sure as butters isn't $item[url]

Offering 500 points because it's important!
0
Comment
Question by:seopher
3 Comments
 
LVL 14

Expert Comment

by:Aamir Saeed
Comment Utility
Please try this function,

function downloadfile($file,$ctype){
      header("Pragma: public");
      header("Expires: 0");
      header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
      header("Cache-Control: private",false);
      header("Content-Type: $ctype;");                  
      header('Content-Disposition: attachment; filename='.basename($file).';');
      header("Content-Length: ".filesize($file).";");
      readfile($file);
}
0
 
LVL 16

Accepted Solution

by:
OliWarner earned 500 total points
Comment Utility
Just have an array of arrays. and access them like so: $arr['enclosure']['url|length|type']
0
 
LVL 3

Author Comment

by:seopher
Comment Utility
Ugh, thanks I was being rather dumb, that's done the trick perfectly.

Nice work.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now