0
I’m trying to import files xml
into the database.
In this example, I would have 2 arches xml
to import.
Note: XML is a road transport CTS.
I tried to do it this way:
$i = 1;
$TotalArquivos = count($_FILES['arquivo']);
if($TotalArquivos==$i)
{
echo $TotalArquivos." <<< TOTAL >>> ";
} else
{
foreach($_FILES['arquivo'] as $file)
{
if($_FILES['arquivo']['tmp_name'][$i]==false) exit; //---> linha 39 do arquivo importarCET.php
$xml[$i] = simplexml_load_file($_FILES['arquivo']['tmp_name'][$i]);
print_r(json_encode($xml[$i]))."<Br>";
$i++;
}
}
That way, my idea was within the $i, count how many you have and stop altogether. But he keeps searching... and generates the following error:
A PHP Error was encountered Severity: Notice Message: Undefined offset: 2 Filename: Libraries/importaCTE.php Line Number: 39
Where am I going wrong?
the
$i
must begin from0
because it’s aarray
produced by PHP then starts with0
, whether it has two positions and 0 and 1 the positions of thearray
– novic
There is also problem in the code, you make a
foreach
and no need to position anything already has the value in the othervariavel
– novic
Right. I tried N forms, I used $i=0 as well. I tried using $file but was unsuccessful. :-(
– Sr. André Baill
I tried $file[$i] too
– Sr. André Baill
Saw the code?..
– novic