Reputation: 414
I have this code
EDIT: This works now
$eigenesVideoId = array();
$eigenesVideoTitel = array();
$eigenesVideoTags = array();
$counter = 0;
function printEntireFeed($videoFeed, $counter)
{
global $eigenesVideoId;
global $eigenesVideoTitel;
global $eigenesVideoTags;
global $counter;
foreach($videoFeed as $videoEntry)
{
if ($videoEntry->isVideoPrivate() != "1")
{
$eigenesVideoId[$counter] = $videoEntry->getVideoId();
$eigenesVideoTitel[$counter] = $videoEntry->getVideoTitle();
$eigenesVideoTags[$counter] = implode(",", $videoEntry->getVideoTags());
$counter++;
}
}
try
{
$videoFeed = $videoFeed->getNextFeed();
}
catch (Zend_Gdata_App_Exception $e)
{
return;
}
if ($videoFeed) {
printEntireFeed($videoFeed, $counter);
}
}
printEntireFeed($videoFeed, 1);
echo count($eigenesVideoId);
Should put each video that is not private into an array. But the array is always empty, count is always zero.
How to change this recursive function (or outer array variables) to have the arrays filled and for them to be accessible afterwards.
Upvotes: 0
Views: 50
Reputation: 1415
To use $videoFeed->getNextFeed(), i think you must have an initial feed, first.
Also, you are filling array variables from inside a function; But to use variables from outside your function , you must declare them GLOBAL inside your function. Otherwise they are LOCAL. (Or pass them as REFERENCE. Or use RETURN variable at the end of the function and capture it after each call.)
Upvotes: 1