} // function to get a movies vote function getvotes($urlForVotes) { $chnl = curl_init(); $timeout = 5; curl_setopt($chnl, CURLOPT_URL, $urlForVotes); curl_setopt($chnl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($chnl, CURLOPT_CONNECTTIMEOUT, $timeout); $htmlForVotes = curl_exec($chnl); curl_close($chnl); $vote = match('/<span itemprop="ratingCount">(.*)<\\/span>/', $htmlForVotes, 1); return $vote; } // match html from imdb foreach (match_all('/<tr class="(even|odd)">(.*?)<\\/tr>/ms', $html, 2) as $m) { $rank++; $id = match('/<td class="titleColumn">.*?<a href="\\/title\\/(tt\\d+)\\/.*?"/msi', $m, 1); $title = match('/<td class="titleColumn">.*?<a.*?>(.*?)<\\/a>/msi', $m, 1); $year = match('/<td class="titleColumn">.*?<span.*?>\\((.*?)\\)<\\/span>/msi', $m, 1); $rating = match('/<td class="ratingColumn">.*?<strong.*?>(.*?)<\\/strong>/msi', $m, 1); $poster = match('/<td class="posterColumn">.*?<img src="(.*?)"/msi', $m, 1); $votesURL = "http://www.imdb.com/title/" . $id . "/"; $votes = getvotes($votesURL); // create each movie object and set the variables $movie = new Movie(); $movie->setId($id); $movie->setRank($rank); $movie->setTitle($title); $movie->setYear($year); $movie->setRating($rating);
print_r($multiline); // array("class" => "abc", "id => "123", "name" => "\n\t\t<strong>\n\t\t\tName\n\t\t</strong>") /*-----------*/ /* Match All */ /*-----------*/ echo "\n<h2>Match All</h2>\n"; $file = <<<EOF <a href="http://blog.vjeux.com/">Vjeux</a> <a href="http://www.curse.com/">Curse</a> <a href="http://www.google.com/">Google</a> EOF; echo "\nSingle captures: \n"; $singles = match_all($file, '<a href="[^"]+">(.*?)</a>'); print_r($singles); // array("Vjeux", "Curse", "Google") echo "\nArray captures: \n"; $arrays = match_all($file, '<a href="([^"]+)">(.*?)</a>'); print_r($arrays); // array( // array("http://blog.vjeux.com/", "Vjeux"), // array("http://www.curse.com/", "Curse"), // array("http://www.google.com/", "Google")) echo "\nAssociative captures: \n"; $associatives = match_all($file, '<a href="(?P<link>[^"]+)">(?P<name>.*?)</a>'); print_r($associatives); // array( // array("link" => "http://blog.vjeux.com/", "name" => "Vjeux"), // array("link" => "http://www.curse.com/", "name" => "Curse"), // array("link" => "http://www.google.com/", "name" => "Google")) ?> </pre>
// Entrate e uscite fuori dall'orario della discussione per la delibera $regex = "/Alle ore ([^\\s]+) (?:si alternano [a-zA-Z0-9,\\-\\s]+\\sed\\s)?(?:entra(?:no)?|esc(?:e|ono))\\sil?\\sConsiglier[ei]\\sComunal[ei]\\s(.*?)(?:\\se\\ssi\\salternano)?\\./smi"; preg_match_all($regex, $txt, $minout); echo " - # InOut: " . count($minout[0]); // Convocazione delibera (per orario previsto) $regex = "/anno ([A-Z]+), il giorno ([A-Z]+) del mese di ([A-Z]+) alle ore ([0-9]+.[0-9]+)/"; preg_match_all($regex, $txt, $mconvocazione); if (count($mconvocazione[0]) > 0) { echo " - Ora appello: " . $mconvocazione[4][0]; } else { echo " - Ora appello non disponibile"; } // Orario primo appello $regex = "/appello nominale [A-Za-z\\s,-]+\\sore\\s([0-9]+.[0-9]+)/"; preg_match_all($regex, $txt, $mappello); if (count($mappello[0]) > 0) { echo " - Appello nominale: " . $mappello[1][0]; } else { echo " - Appello nominale non disponibile"; } // Orario chiusura seduta $regex = array("/seduta[^\\.]+chiusa[^\\.]+\\sore\\s([0-9]+.[0-9]+)/sm", "/ore ([0-9]+.[0-9]+)[^\\.]+seduta[^\\.]+chiusa/sm", "/ore ([0-9]+.[0-9]+)[^\\.]+chiusa[^\\.]+seduta/sm"); $id = match_all($regex, $txt, $mchiusura); if ($id == -1) { echo " - Chiusura non disponibile"; } else { echo " - Chiusura ore:" . $mchiusura[1][0]; } echo "\n"; } }