Help with $GET[id]

Asked

Viewed 95 times

1

Considering the php below:

<?php
require_once 'gerarxml.php';
/*O gerarxml.php foi uma valiosa contribuição do amigo Guilherme Nascimento:
/questions/240387/gerar-xml-automaticamente/240392?noredirect=1#comment496556_240392 */

$id=$_GET['id'];
if($id==1){

//Categorias
GerarXml('IG', '#href="(?P<link>.*?ig\.com\.br\/)" title="(?P<title>.*?)">#', file_get_contents('http://ig.com.br'),); // nome do site, regex, file_get_contents
} // A sugestão de usar (?P<link>.*?), em /questions/242663/php-file-get-contents-follow-url/242671?noredirect=1#comment497755_242671, dada pelo amigo FernandoVR, foi importante para dar robustez a função gerarxml.php (porque não importa a ordem dos elementos)

//Subcategorias
else if($id==2)
GerarXml('IG', '#href="(?P<link>.*?)" title="(?P<title>.*?)".*image" src=(?P<logo>.*?)"#', file_get_contents('o que vai aqui??'),); // nome do site, regex, file_get_contents
// aqui também há a questão das páginas seguintes (aceito sugestões)

else if($id==3){
GerarXml('IG',re, file_get_contents('o que vai aqui??');
}
?>

I need to capture 3 variable elements of id1 to use in id2 and idem from id2 to id3 ($title, $logo (where available) and $link) That is: id1=>id2=>id3 (id1 homepage, id2 id1 and, id3 id2)

A complicator, I believe, is that these elements (title, logo and url) are generated in the function gerarxml.php using the preg_match_all and foreach ($data[1] as $key => $value)(linked with require_once) In id1 I literally set the url to the file_get_contents 'http://ig.com.br'; but in id2 and id3 I need to use the variable $url;

I tested with another scheme (without using require_once) and using $id2=$url. But id2 only captured the content of the home page (not followed for its respective deployment), and capture equal content for all categories (id1)

  • puts this inside an array and makes a test to see what will be returned, and auto-increments your ID so id 2’s Input it captures id1’s Input and 3’s id2

  • I’m sorry for the beginner’s ignorance, but I could actually show you how to do it?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.