file_get_contents

NicoChaluna

Nuovo Utente
18 Apr 2013
8
0
0
Salve a tutti,

cerco di spiegare il mio problema:

prelevando un risultato da un sito esterno con php, riesco a trasformarlo tramite file get contents in una stringa stampabile..

la mia domanda è: è possibile gestire il risultato di questa stringa?

PHP:
$url="http://sitoesempio.php";
$result = file_get_contents($url);

$aRH=$http_response_header;
$n = count($aRH); // Number of Pieces
  $counter = 0;
  while ($counter <= $n) {
    if(preg_match('@Set-Cookie: (([^=]+)=[^;]+)@i', $aRH["$counter"], $matches)) {
 
       $tot .=  $matches["1"] . ";"; 

    }
    ++$counter;
  }


 
$opts = array('http' =>
    array(
 
        'header'  => 'Content-type: text/html; charset=UTF-8\r\n'.
        "Accept-language: en\r\n" .
        'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/12.0\r\n'.
        'Cookie:' . $tot .'\r\n',
 
    )
);

$tag = 'cane';
$url= "http://urldiriferimento";

 $aHTTP['http']['method']          = 'GET';
 $aHTTP['http']['header']          = "User-Agent: My PHP Script\r\n";
 $aHTTP['http']['header']         .= "Referer: http://sito\r\n";
 $aHTTP['http']['header']        .= "Cookie: $tot\r\n";

 $context = stream_context_create($aHTTP);
 $contents = file_get_contents($url, false, $context); // Send the Request
 $ResponseHeaders = $http_response_header;
 print "<br>$contents<br>";

Questo è il codice da me utilizzato..
per chiarire il mio problema, dovrei introdurre dei checkbox dinamici a fianco dei rispettivi risultati in questo modo: Immagine.png


grazie a tutti per l'attenzione.
 

Discussioni simili