Skip to content

Instantly share code, notes, and snippets.

@jjcodes78
Created March 28, 2017 02:47
Show Gist options
  • Save jjcodes78/a009834b04e4bd0e1a85705c10a9813c to your computer and use it in GitHub Desktop.
Save jjcodes78/a009834b04e4bd0e1a85705c10a9813c to your computer and use it in GitHub Desktop.
// metodo pra obter os dados do estabelecimento
function getIdentificacao($table)
{
$table = $table->nextSibling();
$identificacao = [];
foreach ($table->children() as $tr) {
// monta as $keys de origem de dados
$keys = [
'Nome:',
'Nome Empresarial:',
'Logradouro:',
'Complemento:',
'Tipo Unidade:',
'Atividade Ensino/Pesquisa:'
];
foreach ($keys as $key) {
if ($tr->children(0) != null) {
if ($tr->children(0)->plaintext == $key) {
$td_data = $tr->nextSibling();
foreach ($td_data->children() as $field) {
if ($field->tag == 'td') {
$content = trim($field->plaintext);
$identificacao[] = $content;
}
}
}
}
}
}
return $identificacao;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment