The situation is as follows, I have a script in PHP that does CNPJ queries through the IRS website, however it is returning some errors, I really do not know if they are errors .
HTML / PHP code
consulta.html
<html>
<head>
<title>CNPJ e Captcha</title>
</head>
<body>
<form method="post" action="processa.php">
<p><span class="titleCats">CNPJ e Captcha</span>
<br />
<input type="text" name="CNPJ" maxlength="19" required />
<b style="color: red">CNPJ</b>
<br />
<img src="getcaptcha.php" border="0">
<br />
<input type="text" name="CAPTCHA" maxlength="6" required />
<b style="color: red">O que vê na imagem acima?</b>
<br />
</p>
<p>
<input id="id_submit" name="enviar" type="submit" value="Consultar"/>
</p>
</form>
</body>
</html>
processa.php
<?php
require('funcoes.php');
$cnpj = $_POST['CNPJ'];
$captcha = $_POST['CAPTCHA'];
// pega html resposta da receita
$getHtmlCNPJ = getHtmlCNPJ($cnpj, $captcha);
if($getHtmlCNPJ)
{
// volova os dados em um array
$campos = parseHtmlCNPJ($getHtmlCNPJ);
var_dump($campos);
}
?>
funcoes.php
Since the code of funcoes.php
is too large and would deconfigure the question by leaving it too long, I'll leave the link with the whole code, to see just click here
Now the result:
array(23) {
[0]=> string(18) "17.81X.03X/0X01-XX"
[1]=> string(10) "13/03/2013"
[2]=> string(58) "XXXXXXX - EMPRESA - ME"
[3]=> string(10) "TONER XXXXX"
[4]=> string(90) "X7.X1-X-01 - Comércio varejista especializado
de XXX"
[5]=> array(2) {
[0]=> string(67) "47.X1-X-02 -
Recarga de XXX para equipamentos de XXXXX "
[1]=> string(80)
"95.11-8-00 -Reparação e XXX de XX e de XXXXX XX"
}
[6]=> string(68) "230-5 - XXXXXXXXXXXXXX (DE NATUREZA EMPRESARIA)"
[7]=> string(37) "R GERONIMO DOS SANTOS (JD W XX)"
[8]=> string(2) "55"
[9]=> string(0) ""
[10]=> string(10) "09.X70-XXX"
[11]=> string(15) "NOVA XXXX"
[12]=> string(21) "SAO XXXXXX XXXX"
[13]=> string(2) "SP"
[14]=> string(26) "assessoriaprisma@XXX"
[15]=> string(14) "(11) 4X5-3XX08"
[16]=> string(5) "*****"
[17]=> string(5) "ATIVA"
[18]=> string(10) "13/03/2XXX"
[19]=> string(0) ""
[20]=> string(8) "********"
[21]=> string(8) "********"
["status"]=> string(2) "OK"
}
I do not know if I'm right, but the result should be returned the same way it is returned in the federal revenue. Sorry for my ignorance in the subject and in the PHP language, but if this script is not wrong, how can I do it to format this result?
Alias, for those who want to see live, try it yourself
What do you want?
I need the result to return formatted. How so? For example, a line indicating CNPJ {cnpj} another line indicating SOCIAL REASON {social name}. This is just an example, in short, I need to format the result for the understanding of it.
Note: I know that link-based questions can and probably will get downvotes, but I want to make it clear that my intent is good, since I'm also making a very good functional cnpj queries and I do not intend to remove the link, unless that is removed by some third party