0

I wrote the code, it works as intended. One of the significant problems is character encoding. At the moment in the result file I get:

Our Mothers, Our Fathers Unsere M 'ü' tter, Unsere V 'ä' ter 2013 Drama, War

In excel file I see only Special Character Codes for HTML

The original title does not recognize German characters, but Polish characters do. How could I fix it? I want German or other characters, e.g. French, to display correctly

<?php 
header('Content-type: text/plain; charset=iso-8859-2');
//$url = "https://www.filmweb.pl/film/Korespondent+Bryan-2010-596324";
//$url = "https://www.filmweb.pl/serial/Nasze+matki%2C+nasi+ojcowie-2013-625585";
$url = "https://www.filmweb.pl/film/Go%C5%9Bcie-2022-859440";
$content = file_get_contents($url);

$country_x = explode( '<div class="filmInfo__info" itemprop="genre">' , $content );
$country_y = explode("</div>" , $country_x[1]);
$country = strip_tags($country_y[0]);

$title_x = explode( '<div class="filmCoverSection__titleDetails">' , $content );
$title_y = explode("</h1>" , $title_x[1] );
$title = strip_tags($title_y[0]);

$originalTitle_x = explode( '<div class="filmCoverSection__originalTitle">' , $content );
$originalTitle_y = explode("</div>" , $originalTitle_x[1]);
$originalTitle = strip_tags($originalTitle_y[0]);

$year_x = explode( '<div class="filmCoverSection__year">' , $content );
$year_y = explode("</div>" , $year_x[1] );
$year = strip_tags($year_y[0]);

$director_x = explode( '<div class="filmInfo__info cloneToCast cloneToOtherInfo" data-type="directing-info">' , $content );
$director_y = explode("</div>" , $director_x[1] );
$director = strip_tags($director_y[0]);

require_once 'PHPExcel.php';
require_once 'PHPExcel/IOFactory.php';

$objPHPExcel = PHPExcel_IOFactory::load("test.xlsx");
$objPHPExcel->setActiveSheetIndex(0);

$objPHPExcel->getActiveSheet()->SetCellValue('B3'.$row, $title);
$objPHPExcel->getActiveSheet()->SetCellValue('C3'.$row, $originalTitle);
$objPHPExcel->getActiveSheet()->SetCellValue('D3'.$row, $year);
$objPHPExcel->getActiveSheet()->SetCellValue('E3'.$row, $country);
$objPHPExcel->getActiveSheet()->SetCellValue('F3'.$row, $director);

$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save('test.xlsx');
?>

All I found on stackoverflow. Nothing helped. Nothing worked. I tried adding character encoding to phpexcel, php and html

0 Answers0