Problém je, že ostatní názvy to vypisuje všechny, potřeboval bych ale vypsat jeden název...
Aktuálně to dělá: Název ostatní: anglický-The Jungle Book;slovenský-Kniha džunglí
Když dám třeba $nazev[$1], $nazev[$2] aby to vypsalo jen (jeden název)...
<?php
include 'global.php';
$host = 'host';
$db = 'db';
$user = 'user';
$pass = 'pass';
$charset = 'utf8';
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
$pdo = new PDO($dsn, $user, $pass, $opt);
$stmt = $pdo->query('SELECT SQL_CALC_FOUND_ROWS * FROM `filmy` WHERE `id` =600');
while ($row = $stmt->fetch())
{
$id = $row['id'];
$name1 = str_replace(" ", "+", $name = $row['nazev']);
$name_en = $row['nazev_original'];
$year= $row['rok'];
//diakritiky
setlocale(LC_ALL, 'czech');
$name2 = iconv("utf-8", "us-ascii//TRANSLIT", $name1);
echo $name2;
//diakritiky
$html = file_get_html('http://www.csfd.cz/hledat/?q='.$name2.'+'.$year.'');
}
$filmy = '';
$i = 0;
foreach( $html->find('#search-films li') as $film_html){
$i++;
$film = str_get_html($film_html);
$filmy[$i]['nazev'] = $film->find('a.film', 0)->innertext;
$el_type = $film->find('.film-type', 0);
$filmy[$i]['typ'] = $el_type ? $el_type->innertext : null;
$filmy[$i]['rating'] = csfdRating( $film->find('a.film', 0)->class );
$filmy[$i]['id'] = csfdId( $film->find('a.film', 0)->href );
$filmy[$i]['rok'] = csfdHledatRok( $film );
}
if(!$filmy AND $html->find('#pg-film', 0)){
$info = $html->find('.info', 0);
$filmy[1]['nazev'] = trim( $info->find('h1', 0)->innertext );
//echo $info->find('.origin', 0)->innertext;
$filmy[1]['rok'] = csfdHledatRok( $info->find('.origin', 0) );
$filmy[1]['id'] = csfdId( $html->find('.trivia a', 0)->href );
$filmy[1]['typ'] = '';
$filmy[1]['rating'] = csfdConvertRating( $html->find('#rating .average', 0)->innertext );
}
foreach($filmy as $film){
$iddd = $film['id'];
$rok = $film['rok'];
$nazev = $film['nazev'];
}
?>
<?php
$dom = new domDocument;
$csfd = file_get_contents("http://www.csfd.cz/film/$iddd");
$html = (ord($csfd[0]) == 31) ? gzdecode($csfd) : $csfd;
@$dom->loadHTML($html);
$dom->preserveWhiteSpace = false;
$xpath = new DOMXPath($dom);
$nazvy = array();
$zeme = array();
$names_other = "";
$nodes = $xpath->query("//h1[@itemprop='name']");
$names_cs = $nodes->item(0)->nodeValue;
foreach($xpath->query("//ul[@class='names']/li/h3") as $li) {
$nazvy[] = $li->nodeValue;
}
foreach($xpath->query("//ul[@class='names']/li/img") as $li) {
$zeme[] = $li->getAttribute('alt');
}
for($i=0;$i<count($nazvy);$i++){
if($i==count($nazvy)-1)
$names_other .= $zeme[$i]."-".$nazvy[$i];
else
$names_other .= $zeme[$i]."-".$nazvy[$i].";";
}
$nodes = $xpath->query("//h2[@class='average']");
$hodnoceni = str_replace('%', '', $nodes->item(0)->nodeValue);
$nodes = $xpath->query("//p[@class='origin']");
$podrobnosti = explode(", ", $nodes->item(0)->nodeValue);
$nodes = $xpath->query("//p[@class='genre']");
$genre = str_replace(' / ', ', ', $nodes->item(0)->nodeValue);
$nodes = $xpath->query("//span[@data-truncate='340']");
$hraji = $nodes->item(0)->nodeValue;
$nodes = $xpath->query("//div[@data-truncate='570']");
$popis = $nodes->item(0)->nodeValue;
$nodes = $xpath->query("//img[@class='film-poster']");
$poster_url = "http:".$nodes->item(0)->getAttribute('src');
?> Název CZ: <?php echo $names_cs; ?> </br> <?php
?> Název ostatní: <?php echo $names_other; ?> </br> <?php
?> Rok: <?php echo $rok; ?> </br> <?php
?> Žánry: <?php echo $genre; ?> </br> <?php
?> Hodnocení: <?php echo $hodnoceni; ?> </br> <?php
?> Hrají: <?php echo $hraji; ?> </br> <?php
?> Plakát: <?php echo $poster_url; ?> </br> <?php
?> Popis: <?php echo $popis; ?> </br> <?php
?>