Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8351121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:31:59+00:00 2026-06-09T08:31:59+00:00

UPDATED CODE <?php #header( Content-Type: application/xml ); function doLoop($arr = array()) { global $newsStory;

  • 0

UPDATED CODE

  <?php
#header( "Content-Type: application/xml" );

    function doLoop($arr = array())
{
global $newsStory;
foreach( $arr as $r )
{
 //check if we're dealing with an array (multiple links)
        if ( is_array($r) === true )
        {
        //loop through the array and work with each link
        foreach ( $r as $link_)
    //check if link is an array
    if ( is_array($link_) ){doLoop($link_); continue;}
    // //end of third dimension array found
        ## gets url from database as outlined above.
        $xmlUrl = $link_;
        #Loads the url above into XML    
        $ConvertToXml = simplexml_load_file($xmlUrl);
        # -> Setup XML
        $newsStory[] = $ConvertToXml->channel->item;
        }//end of loop
        continue;//move on
 }//end of is array

        //if we get here, we know that only $r is not an array, just a value, so:
        ## gets url from database as outlined above.
        $xmlUrl = $r;
        #Loads the url above into XML    
        #$ConvertToXml = simplexml_load_file($xmlUrl);
         # -> Setup XML
        #$newsStory[] = $ConvertToXml->channel->item;
        $newsStory[] = $r;
        print_r($newsStory);



}//end of function

## Loop through results from mysql
try{
    #connection string
        // $dbconn = new PDO('mysql:host=localhost;port=3306;dbname=thedb',array(PDO::ATTR_PERSISTENT => true));
        $dbconn = new PDO('mysql:host=localhost;port=3306;dbname=thedb','root','toshiba1',array(PDO::ATTR_PERSISTENT => true));
        $q = $dbconn->prepare("SELECT FW_ArtSrcLink FROM FW_ArtSrc WHERE OneSet=1 and leagID=20");
    #call stored proc
        $q->execute();
    #get the rows into an array
        $result = $q->fetchAll();
        $newsStory = array();
doLoop($result);



    # -----> Load News Stories
        for($i = 0;$i<sizeof($newsStory); $i++){
                    //print_r($newsStory);
                    echo "<a href='".$newsStory[$i]->link."'>".$newsStory[$i]->title."</a><br />";
                    echo $newsStory[$i]->description;
                    echo '<hr>';
        }   // for()

} // try

catch(Exception $e){
    $errorPg='errors/fanwire_loop.php';
    $pageDateOfError = $e->getMessage().'on:'.'aggregate_looping.php'.' on '.date('l jS \of F Y h:i:s A');  # inc. details of error
    file_put_contents($errorPg,$pageDateOfError, FILE_APPEND | LOCK_EX);
} // catch


?>

Output of print_r():
img2

Another example of output from print_r():
6

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:32:02+00:00Added an answer on June 9, 2026 at 8:32 am

    This is beginning to get really confusing.

    Your code is a mess, so I’m going to start off fresh here.

    You say print_r($result) returns this:

    Array ( [0] => Array ( [FW_ArtSrcLink] => http://sports.espn.go.com/espn/rss/tennis/news [0] => http://sports.espn.go.com/espn/rss/tennis/news ) [1] => Array ( [FW_ArtSrcLink] => http://sports.yahoo.com/tennis/rss.xml [0] => http://sports.yahoo.com/tennis/rss.xml ) [2] => Array ( [FW_ArtSrcLink] => http://bleacherreport.com/articles;feed?tag_id=12 [0] => http://bleacherreport.com/articles;feed?tag_id=12 )
    

    So there are three arrays in that var, each containing two links.

    So, two simple foreach loops should easily be able to deal with this:

    foreach ($result as $value )
    {
    
      if ( is_array($value) )
      {
         foreach ( $value as $secondValue )
         {
    
    
         }
    
         continue;
    
      }
    
    }
    

    Should be that simple.

    We will have all the processing in a function.

    function processLink( $link , $appendArr )
    {
    
        ## gets url from database as outlined above.
        $xmlUrl = $link;
        #Loads the url above into XML    
        $ConvertToXml = simplexml_load_file($xmlUrl);
        # -> Setup XML
        $appendArr[] = $ConvertToXml->channel->item;
    
    }
    

    So, the end result should be:

    function processLink( $link , $appendArr )
    {
    
       ## gets url from database as outlined above.
       $xmlUrl = $link;
       #Loads the url above into XML    
       $ConvertToXml = simplexml_load_file($xmlUrl);
       # -> Setup XML
       $appendArr[] = $ConvertToXml->channel->item;
    
    }
    
    $dbconn = new PDO('mysql:host=localhost;port=3306;dbname=thedb','root','toshiba1',array(PDO::ATTR_PERSISTENT => true));
    $q = $dbconn->prepare("SELECT FW_ArtSrcLink FROM FW_ArtSrc WHERE OneSet=1 and leagID=20");
    $q->execute();
    $result = $q->fetchAll();
    $newsStory = array();
    
    foreach ($result as $value )
    {
    
        if ( is_array($value) )
        {
           foreach ( $value as $secondValue )
           {
              processLink($secondValue , &$newsStory);
           }
    
        continue;
    
        }
    
        processLink($value , &$newsStory);
    
    }
    
    print_r($newsStory);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

test.php code: $fileloc = 'audio.mp3'; header('Content-type: audio/mpeg'); header(Content-disposition: inline; filename=$filename); header('Content-Length:'.filesize($fileloc)); readfile($fileloc); html code:
I've set the PHP character set to utf-8 : header('Content-Type: text/html; charset=utf-8'); I've set
I use JEditable for making edit field which following code: $(function() { $(.field).editable(http://localhost/index.php/welcome/update_record, {
Im trying to update the contents of an element after running some php code.
In my CMS I've added this code <div><?php include(my_contact_form.php) ?></div> which updates to a
I have updated code for ActiveX functionality which already installed on client(in their Windows
EDIT : Scroll down to see the updated code. I would like to build
I updated my code with string dates created with new Date and added back
I updated my code like Andro wrote about to me: public class ZiiziiActivity extends
Okay I have updated my code quite a bit. I am getting a new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.