Forum Moderators: coopster

Message Too Old, No Replies

PHP: gzuncompress Function

         

jonny0000

8:18 am on Sep 9, 2011 (gmt 0)

10+ Year Member



Having a problem using gzuncompress. The below seems to work on an unzipped feed, however not on a zipped.

Anyone had any similar experiences using gzuncompress?

<?php


function getFeedXML($sUrl, $bCompressed=false)
{
if ($bCompressed===true)
{
return gzuncompress(file_get_contents($sUrl));
}
return file_get_contents($sUrl);
}

$oXML = new SimpleXMLElement(getFeedXML("Enter-Zipped-Feed-URL", true));

foreach($oXML->channel->item as $item)
{
echo $item->Field1."<br/></h1>\n";
echo $item->Field2."<br/>\n";
echo $item->Field3."<br/>\n";
echo $item->Field4."<br/>\n";
echo $item->Field5."<br/>\n";
echo "------------------------------<br/>\n";
if (++$count == 7) {
break;
}
}
?>

coopster

11:41 am on Oct 6, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The manual page for this function has always stated that the data parameter value passed in should be "The data compressed by gzcompress()."

[php.net...]

If this is not the case, you may either be using the incorrect function or may need to consider alternatives. The User Contributed notes on the manual page may offer some direction or alternative thoughts for your consideration.