php - Included File Gets Me Undefined Variables -


couldn't find answer solves codes issue.

file.php:

if(isset($_get['season1'])) {      $season1 = $_get['season1'];     $url = 'http://www.imdb.com/title/'.$season1.'/episodes?season=1';      $imdb_content = file_get_contents($url);     $html = str_get_html($imdb_content);      //grabbed content     $resultarray = array();     foreach($html->find('strong a[itemprop="name"]') $results) {         $resultarray[] = $results;     }      echo $resultarray[0];     echo $resultarray[1];  }  else {         header("location: ../"); } 

index.php:

    include("http://example.com/file.php?season1=".urlencode($imdbid)); (...) <div class="row"> <div class="tech-spec-element col-xs-20 col-sm-10 col-md-5"> <span title="episode 1"></span>1 - <?= $resultarray[0]; ?> <div></div> </div> <div class="tech-spec-element col-xs-20 col-sm-10 col-md-5"> <span title="episode 2"></span>2 - <?= $resultarray[1]; ?> <div></div> </div> <div class="tech-spec-element col-xs-20 col-sm-10 col-md-5"> <span title="episode 3"></span>3 - <?= $resultarray[2]; ?> <div></div> </div> <div class="tech-spec-element col-xs-20 col-sm-10 col-md-5"> <span title="episode 4"></span>4 - <?= $resultarray[3]; ?> <div></div> </div> </div> 

i know file.php being loaded fine gives me output when try , use $resultarray[0]; doesn't work , it's undefined.

are including file.php it's web url? why? on different servers? if so, receiving output file, not have access of it's variables. have access included script's variables, must include executed locally.

so, example, if both scripts on same server, in same directory, in index.php can do:

$season = urlencode($imdbid); include 'file.php'; 

and in file.php:

if(isset($season)) {     $season1 = $season;     //...the rest of code 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -