Imdb\Title::locations PHP Method

locations() public method

Obtain filming locations
See also: IMDB page /locations
public locations ( ) : array
return array locations array[0..n] of array[name,url] with name being the name of the location, and url a relative URL to list other movies sharing this location
    public function locations()
    {
        if (empty($this->locations)) {
            $page = $this->getPage("Locations");
            if (empty($page)) {
                return array();
            }
            // no such page
            $tag_s = strpos($this->page['Locations'], '<div id="tn15adrhs">');
            $tag_e = strpos($this->page['Locations'], '</dl>');
            $block = substr($this->page['Locations'], $tag_s, $tag_e - $tag_s);
            $block = substr($block, strpos($block, '<dl>'));
            if (preg_match_all('!<dt>(<a href="(.*?)">|)(.*?)(</a>|</dt>)!ims', $block, $matches)) {
                for ($i = 0; $i < count($matches[0]); ++$i) {
                    $this->locations[] = array('name' => $matches[3][$i], 'url' => $matches[2][$i]);
                }
            }
        }
        return $this->locations;
    }