I am using the following code:


while($row = mysql_fetch_array($sql))

{
$thetest[] = $row[length];
$thename[] = $row[filename];
$theid[] = $row[Id];
}

$aTimes = $thetest;
$iMin = min($aTimes);
$iFill = 3600;
$aFinal = array();
$iTotal = 0;
foreach( $aTimes as $iTime )
{
    if( $iTotal + $iTime <= $iFill )
    {
        $iTotal += $iTime;
        $aFinal[] = $iTime;
    }
    if( $iTotal == $iFill || ($iFill - $iTotal) < $iMin )
    {
        break;
    }
}



print"


<rss version=\"2.0\" xmlns:jwplayer=\"http://rss.jwpcdn.com/\">
<channel>


";







array_walk($aFinal, function ($code,$filename) use ($thename)



{ 





{
	print "
<item>
<title>$code</title>
<description></description>
<jwplayer:image></jwplayer:image>
<jwplayer:source file=\"http://website/demos/mp3/$thename[$filename]\" />
</item>
  ";
    }



});

How can I get the variable for $theid to print in my <description></description> tag? I think I need to place it in the array_walk but I am not sure how to do that. Any idea?

My goal is to create an rss feed from the variables.

Thanks in advance for any help.

    Assuming ID is unique, I would create only one array in 2 dimensions:

    $data = array();
    while($row = mysql_fetch_array($sql))
    {
        $data[$row['Id']] = array(
            'length' => $row[length],
            'filename' => $row[filename]
        );
    }
    // to see the new structure:
    echo "<pre>".print_r($data,1)."</pre>";
    

    Then you just have one array to do a foreach() loop on when you need to iterate through your results.

      Write a Reply...