0
How to turn the output of this function into a array
? In the future I would like to call only the result of a specific line, such as $palavraschave[1]
.
<?php
$url= 'https://www.telelistas.net/ac/acrelandia';
function palavras_chave($pc){
$doc= new DOMDocument();
$doc->loadHTML(file_get_contents($pc));
$finder = new DomXPath($doc);
$tableid="Content_dataListPalavrasChave";
$nodes = $finder->query("//*[contains(concat(' ', normalize-space(@id), ' '), ' $tableid ')]");
foreach ($nodes as $node){
$links= $node->getElementsByTagName("a");
foreach ($links as $link){
//echo $link->getAttribute("href")."<br>";
$linktratado = $link->getAttribute("href")."<br>";
parse_url($linktratado, PHP_URL_PATH);
$keys = explode("/", $linktratado);
echo $keys[5];
}
}
}
palavras_chave("$url");
?>
Awesome! That’s right, thank you very much.
– Lucas Bonafé