SyndicatedPost::enclosures PHP Méthode

enclosures() public méthode

SyndicatedPost::enclosures: returns an array with any enclosures that may be attached to this syndicated item.
public enclosures ( string $type = '/.*/' ) : array
$type string If you only want enclosures that match a certain MIME type or group of MIME types, you can limit the enclosures that will be returned to only those with a MIME type which matches this regular expression.
Résultat array
    function enclosures($type = '/.*/')
    {
        $enclosures = array();
        if (isset($this->item['enclosure#'])) {
            // Loop through enclosure, enclosure#2, enclosure#3, ....
            for ($i = 1; $i <= $this->item['enclosure#']; $i++) {
                $eid = $i > 1 ? "#{$id}" : "";
                // Does it match the type we want?
                if (preg_match($type, $this->item["enclosure{$eid}@type"])) {
                    $enclosures[] = array("url" => $this->item["enclosure{$eid}@url"], "type" => $this->item["enclosure{$eid}@type"], "length" => $this->item["enclosure{$eid}@length"]);
                }
            }
        }
        return $enclosures;
    }