Jump to content

Search the Community

Showing results for tags 'empty key'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I am scrapping an xml feed with the file_get_contents() and explode() function. Some the xml nodes do not exsist; so I am getting an inconsistant array from a for() loop. What would be the best way to keep an array key, created from an explode() function; empty, if there is no corresponding xml node to be scrapped? Currently, when I use the code below; I get all the node's content (that exsisit within the xml document) at the top and then, at the bottom; I get all the empty node's content or basically a empty/blank area. What I am getting is this: pic1.jpg<br/> pic3.jpg<br/> pic5.jpg<br/> <br/> <br/> And... what I want to get is this: pic1.jpg<br/> <br/> pic3.jpg<br/> <br/> pic5.jpg<br/> Here is my XML code (syndicate.xml): <?xml version="1.0" encoding="iso-8859-1"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:enc="http://purl.oclc.org/net/rss_2.0/enc#" xmlns:ev="http://purl.org/rss/1.0/modules/event/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:admin="http://webns.net/mvcb/" > <item> <enc:enclosure resource="pic1.jpg" type="image/jpeg"/> </item> <item> </item> <item> <enc:enclosure resource="pic3.jpg" type="image/jpeg"/> </item> <item> </item> <item> <enc:enclosure resource="pic5.jpg" type="image/jpeg"/> </item> </rdf:RDF> And... here is my PHP code: <?php $rss = file_get_contents("syndicate.xml"); $img = explode("enclosure resource=\"",$rss); for($key = 0; $key < 5; $key++){ $img2 = explode("\"",$img[$key+1]); echo $img2[0]."<br/>\n"; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.