I have the following php structure.
require_once('api.php');
$data = array(
'DETALLES' => array(
array(
'ITEM' => 'N1',
'DESCRIPCION' => 'DESCRIPCION',
)
),
);
$api = new api();
$result = $api->envioDatos(
$data,
'cer',
array(
'guardarPDF' => '../comprobantes/documento-'.$result['num_documento'],
)
);
I have the problem, that in the array (savePDF), only saves the pdf with the name 'document-', not getting the number of the document that I try to obtain and concatenate. this process has to be inside that array since it is predefined from the api.
By doing the process out of $ result () .., I get the document number without problems with $ result ['num_documento'].
I would appreciate your estimated help.
I leave the solution, if the same thing happens to someone.
require_once('api.php');
function generarCodigo($longitud) {
$key = '';
$pattern = '1234567890abcdefghijklmnopqrstuvwxyz';
$max = strlen($pattern)-1;
for($i=0;$i < $longitud;$i++) $key .= $pattern{mt_rand(0,$max)};
return $key;
}
$data = array(
'DETALLES' => array(
array(
'ITEM' => 'N1',
'DESCRIPCION' => 'DESCRIPCION',
)
),
);
$api = new api();
$codAleatorio= generarCodigo(6);
$result = $api->envioDatos(
$data,
'cer',
array(
'guardarPDF' => '../comprobantes/'.$codAleatorio,
)
);
rename("../comprobantes/".$codAleatorio.".pdf", "../comprobantes/guia-".$resultado['folio'].".pdf");
rename("../comprobantes/".$codAleatorio.".xml", "../comprobantes/guia-".$resultado['folio'].".xml");