PHPWord - How to render word formula into html - php

I have a MS Word with table content with formula/equation like this:
Gabriel, Amanda, Lucas e Joelma estão fazendo uma competição para ver quem tem mais figurinhas do álbum da Copa do mundo. Gabriel conseguiu completar 1/5, Amanda 9/10, Lucas colou em seu álbum 7/8, e Joelma 1/2. O ganhador da competição foi
My code is like this right now:
$phpword = \PhpOffice\PhpWord\IOFactory::load($file["tmp_name"]);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpword, 'HTML');
$xmlWriter = new \PhpOffice\Common\XMLWriter(\PhpOffice\Common\XMLWriter::STORAGE_MEMORY, './', \PhpOffice\PhpWord\Settings::hasCompatibility());
$contentHTML = $objWriter->getContent();
preg_match_all('/<table>(.*?)<\/table>/s', $contentHTML, $tables);
array_splice($tables[0], 0, 1);
foreach ($tables[0] as $key => $table) {
preg_match_all('/<tr>(.*?)<\/tr>/s', $table, $questionTables);
foreach ($questionTables as $key2 => $questionTable) {
// table content
}
}
Now I can get all text and image, but not the formula. It is possible to render this? And transform formula into image or base64?

Related

Create a csv file with a lot of txt files

i'm trying to read a lot of txt files and save the first line as a title, and the rest of text as a content, then export to a CSV file.
i create a id for CSV that increase by iteration, but when i have an error that i cant see in the iteration because when it save the content in the array add the last content to this value.
I need to create a CSV with 3 "columns" named, id, titulo and contenido and by each file, save in a array the information. One txt file, one iteration of array.
Sorry for my english.
this is my code:
<?php
/* Cogemos todos los archivos txt de la carpeta archivos del servidor */
$files = glob("archivos/*.txt");
/* Creamos el array para guardar los datos y le metemos la primera línea que es el nombre de los campos a importar */
$datosparacsv=array(array("ID","titulo","contenido"));
/* Creamos el id que tendrá cada campo del array para después poder importar */
$id = 0;
/* Recorremos cada archivo para coger los datos */
foreach($files as $file) {
/* Sacamos el título de la primera línea del archivo txt */
$titulo = trim(fgets(fopen($file, 'r')));
/* Sacamos el resto del contenido pero quitamos la primera linea con el condicional if*/
$archivo = file($file);
foreach ($archivo as $num=>$line){
if ($num==0) {
continue;
}
else{
$contenido .= $line."\n";
}
}
/* Añadimos el contenido extraido al array para luego pasarlo a CSV */
array_push($datosparacsv, array($id,$titulo,$contenido));
/* Sumamos uno al id para que sea único */
$id++;
}
$delimitador = ','; //parameter for fputcsv
$enclosure = '"'; //parameter for fputcsv
//convert array to csv
$archivocsv = fopen('entradas.csv', 'w+');
foreach ($datosparacsv as $data_line) {
fputcsv($archivocsv, $data_line, $delimitador, $enclosure);
}
$data_read="";
rewind($archivocsv);
//read CSV
while (!feof($archivocsv)) {
$data_read .= fread($archivocsv, 8192); // will return a string of all data separeted by commas.
}
fclose($archivocsv);
echo $data_read;
Example of files to read.
File 1.txt
Titulo 1
texto 1
File 2.txt
Titulo 2
texto 2
CSV
id, titulo, contenido, 0, Titulo 1, texto 1, 1, Titulo 2, texto 2
Thank you very much mates.
$contenido on line 19 is undefined and it's trying to concatenate a non-existent variable with .=. The $contenido variable also isn't required because each archive line is defined in $datosparacsv.
It's also unnecessary to define $delimitador and $enclosure because the defined values are also the default values.
Here's the correct PHP code with the expected CSV output with comments explaining each modified line.
It also preserves new lines and spaces in content as required.
<?php
/* Cogemos todos los archivos txt de la carpeta archivos del servidor */
$files = glob("archivos/*.txt");
/* Creamos el array para guardar los datos y le metemos la primera línea que es el nombre de los campos a importar */
$datosparacsv = array(
array(
"ID",
"titulo",
"contenido"
)
);
/* Creamos el id que tendrá cada campo del array para después poder importar */
$id = 0;
foreach($files as $file) {
/* Sacamos el resto del contenido pero quitamos la primera linea con el condicional if*/
$archivos = file($file);
// Remove and retrieve CSV heading values from each file with array_shift instead of a conditional in each $archivo iteration
$titulo = trim(array_shift($archivos));
// Append to the ID and title to the CSV data array with $datosparacsv[] instead of array_push() while incrementing the ID
$datosparacsv[$id + 1] = array(
$id++,
$titulo,
''
);
foreach ($archivos as $archivo) {
// Append each line from $archivos with preserved spaces and new lines
$datosparacsv[$id][2] .= $archivo;
}
// Trim leading and trailing whitespace
$datosparacsv[$id][2] = trim($datosparacsv[$id][2]);
}
$archivocsv = fopen('entradas.csv', 'w+');
foreach ($datosparacsv as $data_line) {
// Add the data to the CSV with the default delimiter and enclosure
fputcsv($archivocsv, $data_line);
}
?>
archivos/1.txt
Titulo 1
texto 1
archivos/2.txt
Titulo 2
texto 2
texto3
texto4
This saves entradas.csv with this data.
ID,titulo,contenido
0,"Titulo 1","texto 1"
1,"Titulo 2","texto 2
texto3
texto4"
i use this forme because i can format my anser better.
i need that the whole content of the file less the first line was in the column $contenido.
Now, with your code, works fine but if the same file has more than one line after content, it uses each line as a new line of the result.
For example i use now this files
Archivo 1.txt
Titulo 1
texto 1,texto 1
Some more text in file 1
Archivo 2.txt
Titulo 2
texto 2, texto 2, texto 2, texto 2, texto 2, texto 2
Some text 2 of the same archive
and this generates this entradas.csv
ID,titulo,contenido
0,"Titulo 1","texto 1,texto 1"
1,"Titulo 1",
2,"Titulo 1","Some more text in file 1"
3,"Titulo 2","texto 2, texto 2, texto 2, texto 2, texto 2, texto 2"
4,"Titulo 2",
5,"Titulo 2","Some text 2 of the same archive"
But i need that:
ID,titulo,contenido
0,"Titulo 1","texto 1,texto 1
Some more text in file 1"
1,"Titulo 2","texto 2, texto 2, texto 2, texto 2, texto 2, texto 2
Some text 2 of the same archive"
It's important that the contents saves all spaces and \n that they have in the txt file because this txt files are posts of a blog.
An example of one file.txt
¿Como puedo comer galletas?<-- Title
Las galletas se comen con la boca, poco a poco masticando.
<h2>¿Cuántos sabores de galletas hay?</h2>
Pues hay de todos los que puedas imaginar.
and all of this text after title have to stay in the same line saving \n and all.
One file only one line in the CSV.
thank you very much and im sorry for my english.

Reading csv file columns and writing them to a new file

I've been trying to read a csv file and extract the first two columns and save it into another csv file.
The csv file is tab separated. The code is written do show it on the webpage but when it comes to writing the csv file. It prints on a new line which I don't want. Can anyone tell me what I'm doing wrong or what should I add to get the output in one line per row?
$string = <<<CSV
"IRC_01T_00K_002" "Bonjour monsieur, je m'appelle Léon Bop j'habite au Sénégal, j'ai 28ans. J'étais religieux moine bénédictin et je viens de quitter la vie religieuse il y a 2ans. J'ai fait l'hôtellerie comme la plonge, la sécurité et équipier de cuisine, actuellement je suis commerçant, et depuis quelques temps je cherche un correspondant canadien pour venir immigrer au Canada, puisque c'est mon pays de rêve.\
Voilà mes coordonnées:\
leonbop#gmail.com\
+221775797837." "Wrong Channel" "2018-10-26 13:57:16" "DE8B33B0-C68F-11E8-8BFB-0242AC110004" "2018-10-26 13:57:16" "DE8B33B0-C68F-11E8-8BFB-0242AC110004"
"IRC_01T_00K_002" "bonjour le Canadian immigration je suis au Congo je suis un chauffeur" "Wrong Channel" "2018-10-12 15:53:29" "DE8B33B0-C68F-11E8-8BFB-0242AC110004" "2018-10-12 15:53:29" "DE8B33B0-C68F-11E8-8BFB-0242AC110004"
"IRC_031_000_008" "Thnks so much. I will apply before her status expires. You guys are so helpful \
. I am lucky that I am in canada in people like you ." "Chat Conclusion" "2018-10-24 17:41:50" "380922FF-AB0E-11E8-80D2-0242AC110004" "2018-10-24 17:41:50" "380922FF-AB0E-11E8-80D2-0242AC110004"
"IRC_031_000_008" "Ok thanks a lot" "Chat Conclusion" "2018-10-19 04:19:35" "A4D460D3-F448-1693-BA91-C6A0A40998BB" "2018-10-19 04:19:35" "A4D460D3-F448-1693-BA91-C6A0A40998BB"
CSV;
//$string = str_replace(array('\\','/','\\\\','*','"','<','>','|',"'"), '', $string);
$fp=fopen('test13.csv','w');
$handle = fopen("data://text/plain," . $string, "r");
if ($handle) {
while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE)
{
//$num = count($data);
for ($c=0; $c < 2; $c++)
{
echo $data[$c] . "<br />\n";
$data[$c] = str_replace(array('\\','/','\\\\','*','"','<','>','|',"'"), '', $data[$c]);
$data[$c] = preg_replace('/^\h*\v+/m', '', $data[$c]); // remove empty lines
$data[$c] = trim($data[$c]);
fwrite($fp,$data[$c]);
fwrite($fp,"\t");
//fwrite($fp, $data[$c]);
}
fwrite($fp,"\n");
}
fclose($fp);
fclose($handle);
}
Output:
IRC_01T_00K_002 Bonjour monsieur, je mappelle Léon Bop jhabite au Sénégal, jai 28ans. Jétais religieux moine bénédictin et je viens de quitter la vie religieuse il y a 2ans. Jai fait lhôtellerie comme la plonge, la sécurité et équipier de cuisine, actuellement je suis commerçant, et depuis quelques temps je cherche un correspondant canadien pour venir immigrer au Canada, puisque cest mon pays de rêve.
Voilà mes coordonnées:
leonbop#gmail.com
221775797837.
I expect the output to be: "first column" \t "second column". The new csv file created should have two columns and the second column value should be in one single line rather than multiple lines.
You have newlines in the second column of the CSV file. You can replace them with spaces:
data[$c] = str_replace("\n", " ", $data[$c]);

(FPDF, PHP, SQL) table values after first page gets messy

I am using PHP and fPDF to create a PDF "invoice" and everything works perfectly fine on the first page but when the table has to go to the second page it only returns the first value from the sql query and everything goes to the rest goes to the third page and so on.
This is the code that loops the table rows
$sql=sprintf("SELECT * FROM rostosativos_invoice where id_proposta = '".$_GET['id']."';");
$res=mysqli_query($link, $sql);
while ($r=mysqli_fetch_assoc($res)){
// produto = posição 5
// quantidade = posição 7
// precouni = posição 6
// soma = posição 9
//multicell
$cellWidth=120;//tamanho da cell
$cellHeight=6.5;//altura da cell
//verificar se o texto passa a cell
if($pdf->GetStringWidth($r['produto']) < $cellWidth){
//se não, não fazer nada
$line=1;
}else{
//~se estiver, ~então calcular a altura necessária para a cobrir a cell
//ao dividir o texto para ajustar ao tamanho da cell
//~depois contar quantas linhas são necessãrias para ajustar o texto na cell
$textLength=strlen($r['produto']); //total text length
$errMargin=10; //cell com margem de erro, just in case
$startChar=0; //posição inicial para cada linha
$maxChar=0; //Máxima caracteres numa linha, para incremetar mais tarde
$textArray=array(); //Guardar as strings em cada linha
$tmpString=""; //Guardar a string numa linha temporária
while($startChar < $textLength){ //loop até ao fim do texto
//loop até chegar ao máximo de caracteres
while(
$pdf->GetStringWidth( $tmpString ) < ($cellWidth-$errMargin) &&
($startChar+$maxChar) < $textLength ) {
$maxChar++;
$tmpString=substr($r['produto'],$startChar,$maxChar);
}
//mover startChar para a próxima linha
$startChar=$startChar+$maxChar;
//depois adicionar para o array para saber quantas linhas serão necessárias
array_push($textArray,$tmpString);
//reset maxChar e tmpString
$maxChar=0;
$tmpString='';
}
//receber o numero de linhas
$line=count($textArray);
}
//usar MultiCell em vez de Cell
//mas primeiro, como a MultiCell é sempre tratada como fim de linha, precisamos de
//definir manualmente a posição xy para a próxima cell ficar ao lado.
//guardar a posição x e y antes de escrever a multicell
$xPos=$pdf->GetX();
$yPos=$pdf->GetY();
$pdf->MultiCell($cellWidth,$cellHeight,$r['produto'],1,'L');
//receber a posição para a próxima cell ao lado da multicell
//e equilibrar o x com o tamanho da multicell
$pdf->SetXY($xPos + $cellWidth , $yPos);
//escrever as cells
$pdf->Cell(15,($line * $cellHeight),$r['quantidade'],1,0); //adaptar a altura ao número de linhas
$pdf->Cell(10,($line * $cellHeight),'UNI',1,0); //adaptar a altura ao número de linhas
$pdf->Cell(25,($line * $cellHeight),$r['precouni'].chr(128),1,0); //adaptar a altura ao número de linhas
$pdf->Cell(25,($line * $cellHeight),$r['soma'].chr(128),1,1); //adaptar a altura ao número de linhas
}
This is the full PHP code:
class PDF extends TFPDF {
// Page Header
function Header() {
require("../config.php");
$rows = mysqli_query($link, "SELECT * FROM rostosativos_invoice INNER JOIN rostosativos_empresas ON rostosativos_invoice.empresa = rostosativos_empresas.empresa where id_proposta ='".$_GET['id']."';");
$r = mysqli_fetch_assoc($rows);
$id_empresa = $r['id_empresa'];
$idproposta = $r['id_proposta'];
$responsavel = $r['responsavel'];
$empresa = $r['empresa'];
$data = $r['data_registo'];
$contribuinte = $r['contribuinte'];
$assunto = $r['assunto'];
$refcliente = $r['refcliente'];
// Logo
$this->SetY(4);
$this->Image('../logo.png',10,6,30);
// Arial bold 15
$this->SetFont('Arial','B',9);
// Move to the right
$this->Cell(90);
// Title
$this->Cell(100,10,iconv('UTF-8', 'windows-1252','Sede: Rua Azenha dos Latoeiros, 1-A || 2580-557 Ribafria '),'LTR',0,'C');
$this->Ln(5);
$this->Cell(90);
$this->Cell(100,10,iconv('UTF-8', 'windows-1252','Oficina: Estrada Nacional nº1 km 33.3'),'LR',0,'C');
$this->Ln(5);
$this->Cell(90);
$this->Cell(100,10,iconv('UTF-8', 'windows-1252','Quinta do Chacão, Casal Machado 2580-364 Alenquer '),'LR',0,'C');
$this->Ln(5);
$this->Cell(90);
$this->Cell(100,10,iconv('UTF-8', 'windows-1252','E-mail: geral#rostosativos.com'),'LR',0,'C');
$this->Ln(5);
$this->Cell(90);
$this->Cell(100,10,iconv('UTF-8', 'windows-1252','www.rostosativos.com'),'LR',0,'C');
$this->Ln(5);
$this->Cell(90);
$this->Cell(100,10,iconv('UTF-8', 'windows-1252','www.facebook.com/rostosativos/'),'LBR',0,'C');
// Line break
$this->SetFont('Arial','',12);
$this->Ln(15);
$this->Cell(100 ,5,'',0,0);
$this->Cell(35 ,5,'Proposta: ',0,0);
$this->Cell(34 ,5, $idproposta,0,1);//end of line
$this->Cell(100 ,5,'',0,0);
$this->Cell(35 ,5,iconv('UTF-8', 'windows-1252','Ref. Cliente: '),0,0);
$this->Cell(34 ,5,$refcliente,0,1);//end of line
$this->Cell(100 ,5,'',0,0);
$this->Cell(35 ,5,iconv('UTF-8', 'windows-1252','N.º Contribuinte: '),0,0);
$this->Cell(34 ,5,$contribuinte,0,1);//end of line
$this->Cell(100 ,5,'',0,0);
$this->Cell(35 ,5,'Data: ',0,0);
$this->Cell(34 ,5,$data,0,1);//end of line
$this->Ln(5);
//billing address
$this->Cell(100 ,5,'Proposta para:',0,0);//end of line
$this->Cell(100 ,5,'Assunto da proposta:',0,1);//end of line
//add dummy cell at beginning of each line for indentation
$this->Cell(10 ,5,'',0,0);
$this->Cell(90 ,5,iconv('UTF-8', 'windows-1252',$empresa),0,0);
$this->Cell(10 ,5,'',0,0);
$this->Cell(90 ,5,iconv('UTF-8', 'windows-1252',$assunto),0,1);
$this->Cell(10 ,5,'',0,0);
$this->Cell(90 ,5,iconv('UTF-8', 'windows-1252',$responsavel),0,1);
$this->Ln(2);
//invoice contents
$this->SetFont('Arial','B',12);
$this->Cell(120 ,6.5,iconv('UTF-8', 'windows-1252','Designação'),1,0);
$this->Cell(15 ,6.5,'Qtd.',1,0);
$this->Cell(10 ,6.5,'UNI',1,0);
$this->Cell(25, 6.5,iconv('UTF-8', 'windows-1252','Preço UNI.'),1,0);
$this->Cell(25 ,6.5,'Total',1,1);//end of line
}
function Footer() {
require("../config.php");
//~Tabela de Preço, etc..
$this->SetY(-20);
$sql=sprintf("SELECT * FROM rostosativos_invoice where id_proposta = '".$_GET['id']."' ORDER BY id DESC LIMIT 1;");
$res=mysqli_query($link, $sql);
while ($r=mysqli_fetch_assoc($res)){
$this->SetFont('Arial','',9);
$this->Cell(30, 6,iconv('UTF-8', 'windows-1252','Exclusões:'),0,0);
$this->Cell(15);
$this->Cell(65 ,6,'',0,0);
$this->SetFont('Arial','',11);
$this->Cell(40 ,6,iconv('UTF-8', 'windows-1252','Soma'),0,0);
$this->Cell(15);
$this->Cell(30, 6, $r['totalsoma'].chr(128),1,1,'R');
$this->SetFont('Arial','',9);
$this->Cell(30,6,iconv('UTF-8', 'windows-1252',$r['exclusao1']),0, 'L');
$this->SetFont('Arial','',11);
$this->Cell(15);
$this->Cell(65 ,6,'',0,0);
$this->Cell(40 ,6,iconv('UTF-8', 'windows-1252','Mão de Obra'),0,0);
$this->Cell(15);
$this->Cell(30, 6, $r['maoobra'].chr(128),1,1,'R');
$this->SetFont('Arial','',9);
$this->Cell(30,6,iconv('UTF-8', 'windows-1252',$r['exclusao2']),0, 'L');
$this->SetFont('Arial','',11);
$this->Cell(80 ,6,'',0,0);
$this->Cell(40 ,6,'Valor GLOBAL em EUROS',0,0);
$this->Cell(15);
$this->Cell(30 ,6,$r['precototal'].chr(128),1,1,'R');//end of line
}
// Position at 1.5 cm from bottom
$this->SetY(-9);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Page number
$this->Cell(0,10,iconv('UTF-8', 'windows-1252','Página '.$this->PageNo().'/{nb}'),0,0,'C');
}
}
//A4 width : 219mm
//default margin : 10mm each side
//writable horizontal : 219-(10*2)=189mm
//create pdf object
$pdf = new PDF('P','mm','A4');
$pdf -> AliasNbPages();
//add new page
$pdf->AddPage();
// Add a Unicode font (uses UTF-8)
$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
$pdf->SetFont('DejaVu','',12);
//set font to arial, regular, 12pt
$pdf->SetFont('Arial','',12);
$sql=sprintf("SELECT * FROM rostosativos_invoice where id_proposta = '".$_GET['id']."';");
$res=mysqli_query($link, $sql);
while ($r=mysqli_fetch_assoc($res)){
// produto = posição 5
// quantidade = posição 7
// precouni = posição 6
// soma = posição 9
//multicell
$cellWidth=120;//tamanho da cell
$cellHeight=6.5;//altura da cell
//verificar se o texto passa a cell
if($pdf->GetStringWidth($r['produto']) < $cellWidth){
//se não, não fazer nada
$line=1;
}else{
//~se estiver, ~então calcular a altura necessária para a cobrir a cell
//ao dividir o texto para ajustar ao tamanho da cell
//~depois contar quantas linhas são necessãrias para ajustar o texto na cell
$textLength=strlen($r['produto']); //total text length
$errMargin=10; //cell com margem de erro, just in case
$startChar=0; //posição inicial para cada linha
$maxChar=0; //Máxima caracteres numa linha, para incremetar mais tarde
$textArray=array(); //Guardar as strings em cada linha
$tmpString=""; //Guardar a string numa linha temporária
while($startChar < $textLength){ //loop até ao fim do texto
//loop até chegar ao máximo de caracteres
while(
$pdf->GetStringWidth( $tmpString ) < ($cellWidth-$errMargin) &&
($startChar+$maxChar) < $textLength ) {
$maxChar++;
$tmpString=substr($r['produto'],$startChar,$maxChar);
}
//mover startChar para a próxima linha
$startChar=$startChar+$maxChar;
//depois adicionar para o array para saber quantas linhas serão necessárias
array_push($textArray,$tmpString);
//reset maxChar e tmpString
$maxChar=0;
$tmpString='';
}
//receber o numero de linhas
$line=count($textArray);
}
//usar MultiCell em vez de Cell
//mas primeiro, como a MultiCell é sempre tratada como fim de linha, precisamos de
//definir manualmente a posição xy para a próxima cell ficar ao lado.
//guardar a posição x e y antes de escrever a multicell
$xPos=$pdf->GetX();
$yPos=$pdf->GetY();
$pdf->MultiCell($cellWidth,$cellHeight,$r['produto'],1,'L');
//receber a posição para a próxima cell ao lado da multicell
//e equilibrar o x com o tamanho da multicell
$pdf->SetXY($xPos + $cellWidth , $yPos);
//escrever as cells
$pdf->Cell(15,($line * $cellHeight),$r['quantidade'],1,0); //adaptar a altura ao número de linhas
$pdf->Cell(10,($line * $cellHeight),'UNI',1,0); //adaptar a altura ao número de linhas
$pdf->Cell(25,($line * $cellHeight),$r['precouni'].chr(128),1,0); //adaptar a altura ao número de linhas
$pdf->Cell(25,($line * $cellHeight),$r['soma'].chr(128),1,1); //adaptar a altura ao número de linhas
}
//output the result
$pdf->Output();
$content = $pdf->Output('propostas/'.$_GET['id'].'.pdf','F');
file_put_contents($content);
Make these changes right after you define the PDF and pages.
$pdf = new PDF('P','mm','A4');
$pdf -> AliasNbPages();
$pdf->AddPage();
$pdf->SetAutoPageBreak(false); // add this line and the next
$howhigh = $pdf->GetPageHeight(); // stash the height of the page for later
The next change is in the else where the size of the larger cells is calculated. There is really no reason to go through the data to be added character by character. You can replace that block of code with:
//verificar se o texto passa a cell
if ($pdf->GetStringWidth($r['produto']) < $cellWidth) {
//se não, não fazer nada
$line=1;
} else {
$line = ceil($pdf->GetStringWidth($item[2]));
$line = round($line / $cellWidth,0) + 1;
}
Finally, the actual output of the data needs a little change to account for testing whether or not we need to start a new page. As you'll see the calculation done above are used.
//usar MultiCell em vez de Cell
//mas primeiro, como a MultiCell é sempre tratada como fim de linha, precisamos de
//definir manualmente a posição xy para a próxima cell ficar ao lado.
//guardar a posição x e y antes de escrever a multicell
$xPos=$pdf->GetX();
$yPos=$pdf->GetY();
$total = $yPos + (($line * $cellHeight));
if ($total > $howhigh) { // we will spill to a new page with this cell
$pdf->AddPage(); // so start a new page before we add the cell
$xPos=$pdf->GetX();
$yPos=$pdf->GetY();
}
$pdf->MultiCell($cellWidth,$cellHeight,$r['produto'],1,'L');
//receber a posição para a próxima cell ao lado da multicell
//e equilibrar o x com o tamanho da multicell
$pdf->SetXY($xPos + $cellWidth , $yPos);

Cannot replace some html characters with str_replace()

From the database I receive the following text:
<div onclick="alert('código inyectado');">Texto</div>
[img]http://www.hobbyconsolas.com/sites/hobbyconsolas.com/public/media/image/2015/07/503196-halo-5-guardians-nuevos-datos-campana-cooperativa.jpg[/img]
Y aquí una URL: [url]https://www.google.es/?gws_rd=ssl[/url]
Bueno pues vamos [b]a ver si esto funciona[/b] porque "todavía" no lo sé [i][u]bien[/u][/i]
This text is stored in a variable called $texto. Once htmlspecialchars() applied to the variable, I go through where I´m finding the problem:
$texto = str_replace(""","\"",$texto); //para comillas
$texto = str_replace("<","<",$texto); // para <
$texto = str_replace(">",">",$texto); // para >
But no modification is done. If I remove the character & works, how can I fix this problem?
I'd say don't do that htmlspecialchars() call, and only call str_replace() once:
Code: (Demo)
$texto="<div onclick="alert('código inyectado');">Texto</div>
[img]http://www.hobbyconsolas.com/sites/hobbyconsolas.com/public/media/image/2015/07/503196-halo-5-guardians-nuevos-datos-campana-cooperativa.jpg[/img]
Y aquí una URL: [url]https://www.google.es/?gws_rd=ssl[/url]
Bueno pues vamos [b]a ver si esto funciona[/b] porque "todavía" no lo sé [i][u]bien[/u][/i]";
//$texto=htmlspecialchars($texto);
$texto = str_replace([""","<",">"],['"','<','>'],$texto);
var_export($texto);
Output:
'<div onclick="alert(\'código inyectado\');">Texto</div>
[img]http://www.hobbyconsolas.com/sites/hobbyconsolas.com/public/media/image/2015/07/503196-halo-5-guardians-nuevos-datos-campana-cooperativa.jpg[/img]
Y aquí una URL: [url]https://www.google.es/?gws_rd=ssl[/url]
Bueno pues vamos [b]a ver si esto funciona[/b] porque "todavía" no lo sé [i][u]bien[/u][/i]'
fyrye's suggestion yields this -- if this is what you are shooting for:
'<div onclick="alert('código inyectado');">Texto</div>
[img]http://www.hobbyconsolas.com/sites/hobbyconsolas.com/public/media/image/2015/07/503196-halo-5-guardians-nuevos-datos-campana-cooperativa.jpg[/img]
Y aquí una URL: [url]https://www.google.es/?gws_rd=ssl[/url]
Bueno pues vamos [b]a ver si esto funciona[/b] porque "todavía" no lo sé [i][u]bien[/u][/i]'
It sounds like you're double encoding. To avoid the double encoding you can use.
htmlspecialchars($texto, ENT_QUOTES, 'UTF-8', false);
See: http://php.net/manual/en/function.htmlspecialchars.php

How can I use "for" inside an "array"?

Thank you for your help.
I am working on a new site, i would love to generate a CSV from a XML website.
But i can't use "for (number...)" inside an array.
<?php
// output headers so that the file is downloaded rather than displayed
header('Content-type: text/csv');
header('Content-Disposition: attachment; filename="demo.csv"');
// do not cache the file
header('Pragma: no-cache');
header('Expires: 0');
// create a file pointer connected to the output stream
$file = fopen('php://output', 'w');
// send the column headers
fputcsv($file, array('Column 1', 'Column 2', 'Column 3'));
$json_string = "http://v2.notmaison.be/php/index.php?action=getRealEstateByNotaris&notaris=FRANCE,%20Gilles";
$jsondata = file_get_contents($json_string);
$result = json_decode ($jsondata,true);
$nombre = count($result['results']);
$json = $result['results'][$numero]['im'];
$json_decoded = json_decode($json);
$data = array(
for ($numero = 0; $numero < $nombre ; $numero++) {
Array($result['results'][$numero]['re_ru'],"test2","test3")
);
}
// output each row of the data
foreach ($data as $row) {
fputcsv($file, $row);
}
exit();
?>
I have this error : Parse error: syntax error, unexpected 'for' (T_FOR), expecting ')' in /htdocs/biens3.php on line 25
you should use
for ($numero = 0; $numero < $nombre ; $numero++)
{
$data[] = Array($result['results'][$numero]['re_ru'],"test2","test3");
}
Try declaring $data as an empty Array, then for each $nombre you add an item/Array to $data, something liek this:
$data = Array();
for($numero = 0; $numero < $nombre; $numero++){
$data[] = Array($result['results'][$numero]['re_ru'],"test2","test3");
}
If your goal is to populate the array, instead of this:
$data = array(
for ($numero = 0; $numero < $nombre ; $numero++)
{
Array($result['results'][$numero]['re_ru'],"test2","test3")
);
}
You can first create the array like you're doing, but just create, and
then add the elements with a loop:
$data = []; # shorter syntax than array(), but the same.
for ($numero = 0; $numero < $nombre ; $numero++)
{
$data[] = [
$result['results'][$numero]['re_ru'],
"test2",
"test3"
];
}
The syntax $data[] will push elements to the end of the array. Note
that you actually don't even need to create the array itself. I also
noticed that right after you're looping on the array to output its
contents. And since you don't use $data anywhere else after, you could
eliminate it and ouptup data in the same loop:
for ($numero = 0; $numero < $nombre ; $numero++)
{
fputcsv($file, [
$result['results'][$numero]['re_ru'],
"test2",
"test3"
]);
);
This is a perfect candidate for the use of foreach rather than a for
The code can be simplified down to this
$json_string = "http://v2.notmaison.be/php/index.php?action=getRealEstateByNotaris&notaris=FRANCE,%20Gilles";
$jsondata = file_get_contents($json_string);
$json_obj = json_decode ($jsondata);
$csv_file = fopen('php://output', 'w');
foreach ( $json_obj->results as $result) {
// to use all the fields from the json returned
fputcsv($csv_file, (array)$result);
}
Giving output:
25174,CH-82691-16,0,50.4107048,4.4445519,2,12,1,,3,4,,"Appartement meublé (3ème étage) 2 chambres avec cave et garage.<br/>Hall, séjour, cuisine équipée, sdb, wc, buanderie, 2 chambres.<br/>Balcon avant avec tente solaire. Porte blindée. Cave. Garage. Ascenseur.<br/>",,6000,2,0,-1,95000,10,"Rue Basslé",Charleroi,0,1,0,1,-1,-1,1018,-1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,"FRANCE, Gilles","Maison du notariat de Charleroi",071/41.45.34,071/20.56.56,"Faire offre à partir de: 95000 €","S'adresser en l'étude.",-1,-1,-1,1,-1,-1,-1,-1,-1,-1,1,,,,,,,,,,,,"Classe B",201611231147,201611281115,contact#notairescharleroi.be,notaire.france#skynet.be,,20161109022084,,,HA,,,,,OFF,,2,Appartements,"un appartement",12,Appartement,Appartement,2,1,Gré-à-Gré,,,,,3,Central,4,Equipée,"[""WEBB-AFYESF"",""WEBB-AFYES7"",""WEBB-AFYES9""]",238
22691,CH-82112-16,0,50.4234543,4.4862727,1,8,1,,9,2,,"Maison de rapport avec 2 appartements.<br/>Hall commun de +/- 16 m².<br/>Appartement rez (+/- 45 m²): chambre (+/- 18 m²), séjour-sàm (+/- 10 m²), cuisine (+/- 4 m²), sdb (+/- 2,5 m²), cour arrière.<br/>Appartement 1er étage (+/- 51 m²): séjour-sàm (+/- 29 m²), chambre (+/- 17 m²), sdb (+/- 3 m²).<br/>Grenier aménageable (+/- 70 m²).<br/>Châssis SV.","Libre à l'acte.",6060,2,60,-1,80000,114,"Rue Hanoteau",Gilly,0,-1,0,0,1,-1,594,-1,-1,-1,-1,-1,1,-1,2,2,-1,-1,-1,2,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,"FRANCE, Gilles","Maison du notariat de Charleroi",071/41.45.34,071/20.56.56,"Faire offre à partir de: 80000 €","S'adresser en l'étude.",1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,,,,,,,,,,,,"Classe E",201607191431,201607250944,contact#notairescharleroi.be,notaire.france#skynet.be,,20160228005227,,,HA,,,,,OFF,,1,Maisons,"une maison",8,"Maison de rapport",Opbrengsteigendom,1,1,Gré-à-Gré,,,,,9,"Foyer gaz",2,"Non équipée","[""WEBB-ABZGY2"",""WEBB-ABZGY5""]",238
15311,CH-80259-15,0,50.4291858,4.4990644,1,7,1,,5,2,,"Maison avec jardin.<br/>Sous-sol: cave.<br/>Rez: sàm, living.<br/>Annexe: cuisine, sdb avec wc séparé, buanderie.<br/>Etage: 2 chambres.<br/>Grenier, jardin.<br/>Châssis PVC double vitrage.",,6060,2,432,-1,55000,31,"Rue Brasserie Gillieaux",Gilly,0,-1,1,0,-1,-1,282,-1,-1,1,-1,-1,-1,1,-1,1,-1,-1,-1,1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,"FRANCE, Gilles","Maison du notariat de Charleroi",071/41.45.34,071/20.56.56,"Faire offre à partir de: 55000 €","S'adresser en l'étude.",-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,,,,,,,,,,,,"Classe G",201509011601,201601060955,contact#notairescharleroi.be,notaire.france#skynet.be,G,20150507024064,513,60394,HA,,,,,OFF,,1,Maisons,"une maison",7,"Maison d'habitation",Woonhuis,1,1,Gré-à-Gré,,,,,5,"Central mazout",2,"Non équipée","[""WEBB-9ZXJLP"",""WEBB-9ZXJLS"",""WEBB-9ZXJMS""]",238
24222,CH-82449-16,0,50.4276111,4.472657,4,39,1,,4,2,,"Immeuble de rapport avec commerce (et cour) au rez et 2 appartements.<br/>Sous-sol de 65 m².<br/>Rez commercial de 70 m²: commerce et pièce arrière avec WC. Cour.<br/>1er étage: appartement de 63 m² avec balcon: cuisine, séjour/sàm, hall, 1 chambre, sdb.<br/>2ème étage: appartement de 70 m² avec balcon: cuisine, séjour/sàm, débarras, hall, WC, sdb, 1 chambre.<br/>CC gaz, 3 chaudières séparées.<br/>citerne eau de pluie. Compteurs gaz et électricité séparés.",,6060,2,147,-1,160000,198,"Chaussée de Lodelinsart",Gilly,0,-1,0,0,-1,-1,1682,-1,-1,2,-1,-1,2,-1,2,2,-1,-1,-1,2,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,"FRANCE, Gilles","Maison du notariat de Charleroi",071/41.45.34,071/20.56.56,"Faire offre à partir de: 160000 €","S'adresser en l'étude.",-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,,,,,,,,,,,,"Classe G",201610101349,201610191534,contact#notairescharleroi.be,notaire.france#skynet.be,,20161003008071,,,HA,,,,,OFF,,4,"Bureaux / Commerces","un bureau / commerce",39,"Maison de rapport",Opbrengsteigendom,4,1,Gré-à-Gré,,,,,4,"Central gaz",2,"Non équipée","[""WEBB-AELG3S"",""WEBB-AEVHX6"",""WEBB-AEVHX8"",""WEBB-AEVHXA"",""WEBB-AEVHXC"",""WEBB-AEVHXE""]",238
24617,CH-82546-16,0,50.3780923,4.3711288,1,7,1,,4,1,5,"Sous-sol : caves<br/>Rez-de-chaussée (40 m²) : hall, séjour, cuisine<br/>1er étage (40m²) : hall, 2 chambres, salle de bain <br/>Grenier aménageable<br/>Jardin et cour<br/>Garage<br/>Chauffage central au gaz <br/>Châssis double vitrage PVC et aluminium<br/>R.C.: 431,00 €<br/>Superficie : 3 ares 30 centiares<br/>PEB N° 20161020028100: classe E<br/>Faire offre à partir de 85.000,00 € . <br/>Offre actuelle : 85.000,00 €.<br/> <br/>",,6110,2,330,-1,85000,334,"Rue de Gozée",Montigny-le-Tilleul,3,-1,1,1,1,-1,431,-1,-1,1,-1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,2,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,"FRANCE, Gilles","Maison du notariat de Charleroi",071/41.45.34,071/20.56.56,"Faire offre à partir de: 85000 €","S'adresser en l'étude.",0,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,,,,,,,,,,,,,201610261444,201611080845,contact#notairescharleroi.be,notaire.france#skynet.be,,20161020028100,,,HA,,,,,OFF,,1,Maisons,"une maison",7,"Maison d'habitation",Woonhuis,1,1,Gré-à-Gré,,,5,Bon,4,"Central gaz",1,Présente,"[""WEBB-AF4H3P""]",238
25383,CH-82753-16,0,50.3439488,4.4577754,3,18,1,,,,,"Terrain de 9 ares 58ca.<br/>Lot sous teinte blanche.",,6120,0,958,-1,85000,,"Rue de la Ferrée",Nalinnes,0,-1,0,0,-1,-1,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,"FRANCE, Gilles","Maison du notariat de Charleroi",071/41.45.34,071/20.56.56,"Faire offre à partir de: 85000 €","Sur place.",-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,,,,,,,,,,,,,201612021139,201612021141,contact#notairescharleroi.be,notaire.france#skynet.be,,,,,HA,,,,,OFF,,3,Terrains,"un terrain",18,"Prairies / pâtures",Weide,3,1,Gré-à-Gré,,,,,,,,,"[""WEBB-AG9EJM"",""WEBB-AG9EJP""]",238
18716,CH-81190-16,0,50.4239506,4.4872409,1,7,1,,5,2,,"Maison avec jardin.<br/>Sous-sol: cave avec voussettes.<br/>Rez: hall, séjour-sàm, WC.<br/>Annexe: cuisine, sdb.<br/>1er étage: hall, 3 chambres.<br/>Annexe au 1er étage: 1 chambre, WC, pièce.<br/>Grenier aménageable.<br/>Jardin à l'arrière. Châssis DV en partie et volets en partie.<br/>",,6060,4,220,-1,80000,11,"Rue de la Station",Gilly,0,-1,1,0,1,-1,773,-1,-1,2,-1,-1,1,-1,1,1,-1,-1,-1,1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,"FRANCE, Gilles","Maison du notariat de Charleroi",071/41.45.34,071/20.56.56,"Faire offre à partir de: 80000 €","S'adresser en l'étude.",-1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,,,,,,,,,,,,"Classe G",201602050944,201608081422,contact#notairescharleroi.be,notaire.france#skynet.be,G,20160128025502,528,,HA,,,,,OFF,,1,Maisons,"une maison",7,"Maison d'habitation",Woonhuis,1,1,Gré-à-Gré,,,,,5,"Central mazout",2,"Non équipée","[""WEBB-A6UCCX"",""WEBB-A6UCCY"",""WEBB-A6UCD2""]",238
25159,CH-82686-16,0,50.4253111,4.501545,1,7,1,,,2,,"Maison 3 façades avec jardin.<br/>Sous-sol: caves.<br/>Rez: séjour, sàm avec coin cuisine, WC.<br/>1er étage: hall, 2 chambres.<br/>Grenier aménageable. Jardin.<br/>chauffage au charbon.<br/>Châssis DV PVC sauf un en façade.",,6060,2,350,-1,60000,47,"Rue de la Plateure",Gilly,3,-1,1,0,1,-1,297,-1,-1,1,-1,-1,1,-1,1,1,-1,-1,-1,0,-1,-1,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,"FRANCE, Gilles","Maison du notariat de Charleroi",071/41.45.34,071/20.56.56,"Faire offre à partir de: 60000 €","S'adresser en l'étude.",-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,,,,,,,,,,,,"Classe G",201611221617,201611221625,contact#notairescharleroi.be,notaire.france#skynet.be,,201604280334591,,,HA,,,,,OFF,,1,Maisons,"une maison",7,"Maison d'habitation",Woonhuis,1,1,Gré-à-Gré,,,,,,,2,"Non équipée","[""WEBB-AFXL43"",""WEBB-AFXL4H""]",238
24585,CH-82540-16,0,50.422774,4.4799037,2,12,1,,4,4,,"Appartement (2ème étage) comprenant hall, séjour, cuisine (frigo, four électrique et hotte), sdb avec douche multi confort, chambre.<br/>Balcon arrière, cave.",,6060,1,0,-1,55000,5,"Chaussée de Lodelinsart",Gilly,0,1,0,0,-1,-1,706,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,"FRANCE, Gilles","Maison du notariat de Charleroi",071/41.45.34,071/20.56.56,"Faire offre à partir de: 55000 €","S'adresser en l'étude.",-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,,,,,,,,,,,,"Classe F",201610251409,201610251416,contact#notairescharleroi.be,notaire.france#skynet.be,,20161017025827,,,HA,,,,,OFF,,2,Appartements,"un appartement",12,Appartement,Appartement,2,1,Gré-à-Gré,,,,,4,"Central gaz",4,Equipée,"[""WEBB-AF3GDJ"",""WEBB-AF3GDL""]",238
22272,CH-82012-16,0,50.40205,4.5199634,1,7,1,,3,2,,"Maison avec dépendances et garage.<br/>Rez (+/- 50 m²): hall, cuisine, 1 pièce.<br/>1er étage (+/- 65 m²): hall, 4 chambres.<br/>2ème étage (+/- 60 m²): hall, sdb, 3 chambres.<br/>Grenier (+/- 45 m²) aménageable.<br/>Chauffage central, terrasse, jardin.<br/>RC du n°72: 535€ - RC du n°74: 97€.",,6200,7,228,-1,80000,72/74,"Rue d'Acoz",Châtelet,0,1,1,1,1,-1,632,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,"FRANCE, Gilles","Maison du notariat de Charleroi",071/41.45.34,071/20.56.56,"Faire offre à partir de: 80000 €","S'adresser en l'étude.",-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,,,,,,,,,,,,"Classe G",201606291112,201606291117,contact#notairescharleroi.be,notaire.france#skynet.be,,20160120016969,,,HA,,,,,OFF,,1,Maisons,"une maison",7,"Maison d'habitation",Woonhuis,1,1,Gré-à-Gré,,,,,3,Central,2,"Non équipée","[""WEBB-ABDCWC"",""WEBB-ABDCWJ""]",238
22955,CH-82160-16,0,50.1681918,4.3181224,1,2,1,,9,4,5,"Châlet de 65m² meublé avec jardin comprenant :<br/> <br/>Living, cuisine, 2 chambres, salle de bains <br/>Jardin avec deux chalets <br/>Convecteurs pétrole avec thermostat<br/>Boiler au gaz <br/>PEB : F<br/>",,6440,2,280,-1,50000,314,"Parc Résidentiel Le Bosquet",Fourbechies,4,-1,1,0,-1,1,265,-1,-1,1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,-1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,"FRANCE, Gilles","Maison du notariat de Charleroi",071/41.45.34,071/20.56.56,"Faire offre à partir de: 50000 €","S'adresser en l'étude.",2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,,,,,,,,,,,,,201608081032,201608081036,contact#notairescharleroi.be,notaire.france#skynet.be,,20160707022876,,,HA,,,,,OFF,,1,Maisons,"une maison",2,Châlet,Chalet,1,1,Gré-à-Gré,,,5,Bon,9,"Foyer gaz",4,Equipée,"[""WEBB-ACMC4J"",""WEBB-ACMC4S"",""WEBB-ACMC4X""]",238
25119,CH-82675-16,0,50.4328324,4.467517,1,7,1,4,2,,3,"Maison incendiée 3 façades avec jardin composée de :<br/>Sous-sol : caves.<br/>Rez-de-chaussée : + 43m²<br/>1er étage: + 43m²<br/>Grenier aménageable<br/>Jardin <br/>Offres à partir de 60.000,00€<br/>Offre actuelle : 75.000,00 €<br/><br/><br/> <br/> <br/><br/>",,6060,1,367,-1,60000,111,"Rue Chausteur",Gilly,3,-1,1,0,1,0,609,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,"FRANCE, Gilles","Maison du notariat de Charleroi",071/41.45.34,071/20.56.56,"Faire offre à partir de: 60000 €","S'adresser en l'étude.",0,-1,0,-1,-1,-1,-1,-1,-1,-1,0,,,,,,,,,,,,,201611210950,201612051553,contact#notairescharleroi.be,notaire.france#skynet.be,,,,,HA,,,,,OFF,,1,Maisons,"une maison",7,"Maison d'habitation",Woonhuis,1,1,Gré-à-Gré,4,Oui,3,Mauvais,2,"A installer",,,"[""WEBB-AFWCFT""]",238
Or if you only want specific fields from the json
$json_string = "http://v2.notmaison.be/php/index.php?action=getRealEstateByNotaris&notaris=FRANCE,%20Gilles";
$jsondata = file_get_contents($json_string);
$json_obj = json_decode ($jsondata);
$csv_file = fopen('php://output', 'w');
foreach ( $json_obj->results as $result) {
// to use only specific fields from the input
fputcsv($csv_file, array($result->re_nu, $result->re_ru) );
}
Giving a csv like this
10,"Rue Basslé"
114,"Rue Hanoteau"
31,"Rue Brasserie Gillieaux"
198,"Chaussée de Lodelinsart"
334,"Rue de Gozée"
,"Rue de la Ferrée"
11,"Rue de la Station"
47,"Rue de la Plateure"
5,"Chaussée de Lodelinsart"
72/74,"Rue d'Acoz"
314,"Parc Résidentiel Le Bosquet"
111,"Rue Chausteur"
EDIT for second question
If you want the Images codes included in your output then this would do it
foreach ( $json_obj->results as $result) {
$required = array(); // init an array
// pick fields wanted in resulting csv
$required[] = $result->re_nu;
$required[] = $result->re_ru;
// get the images
$im_codes = json_decode($result->im);
foreach ($im_codes as $im) {
$required[] = 'http://photos.notmaison.be/photos/m' . $im . '.jpg';
}
fputcsv($csv_file, $required);
}
Generated output:
10,"Rue Basslé",http://photos.notmaison.be/photos/mWEBB-AFYESF.jpg,http://photos.notmaison.be/photos/mWEBB-AFYES7.jpg,http://photos.notmaison.be/photos/mWEBB-AFYES9.jpg
114,"Rue Hanoteau",http://photos.notmaison.be/photos/mWEBB-ABZGY2.jpg,http://photos.notmaison.be/photos/mWEBB-ABZGY5.jpg
31,"Rue Brasserie Gillieaux",http://photos.notmaison.be/photos/mWEBB-9ZXJLP.jpg,http://photos.notmaison.be/photos/mWEBB-9ZXJLS.jpg,http://photos.notmaison.be/photos/mWEBB-9ZXJMS.jpg
198,"Chaussée de Lodelinsart",http://photos.notmaison.be/photos/mWEBB-AELG3S.jpg,http://photos.notmaison.be/photos/mWEBB-AEVHX6.jpg,http://photos.notmaison.be/photos/mWEBB-AEVHX8.jpg,http://photos.notmaison.be/photos/mWEBB-AEVHXA.jpg,http://photos.notmaison.be/photos/mWEBB-AEVHXC.jpg,http://photos.notmaison.be/photos/mWEBB-AEVHXE.jpg
334,"Rue de Gozée",http://photos.notmaison.be/photos/mWEBB-AF4H3P.jpg
,"Rue de la Ferrée",http://photos.notmaison.be/photos/mWEBB-AG9EJM.jpg,http://photos.notmaison.be/photos/mWEBB-AG9EJP.jpg
11,"Rue de la Station",http://photos.notmaison.be/photos/mWEBB-A6UCCX.jpg,http://photos.notmaison.be/photos/mWEBB-A6UCCY.jpg,http://photos.notmaison.be/photos/mWEBB-A6UCD2.jpg
47,"Rue de la Plateure",http://photos.notmaison.be/photos/mWEBB-AFXL43.jpg,http://photos.notmaison.be/photos/mWEBB-AFXL4H.jpg
5,"Chaussée de Lodelinsart",http://photos.notmaison.be/photos/mWEBB-AF3GDJ.jpg,http://photos.notmaison.be/photos/mWEBB-AF3GDL.jpg
72/74,"Rue d'Acoz",http://photos.notmaison.be/photos/mWEBB-ABDCWC.jpg,http://photos.notmaison.be/photos/mWEBB-ABDCWJ.jpg
314,"Parc Résidentiel Le Bosquet",http://photos.notmaison.be/photos/mWEBB-ACMC4J.jpg,http://photos.notmaison.be/photos/mWEBB-ACMC4S.jpg,http://photos.notmaison.be/photos/mWEBB-ACMC4X.jpg
111,"Rue Chausteur",http://photos.notmaison.be/photos/mWEBB-AFWCFT.jpg
I need to output in the same time
[""WEBB-AFYESF"",""WEBB-AFYES7"",""WEBB-AFYES9""]
to CSV as
"http://photos.notmaison.be/photos/mWEBB-AFYESF.jpg",
"http://photos.notmaison.be/photos/mWEBB-AFYES7.jpg",
"http://photos.notmaison.be/photos/mWEBB-AFYES9.jpg"

Categories