mercredi 1 juillet 2015

Included File Gets Me Undefined Variables

Couldnt find an answer that solves my codes issue.

file.php:

if(isset($_GET['season1'])) {

$season1 = $_GET['season1'];
$url = 'http://ift.tt/ywvpFl'.$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"]') as $results) {
    $resultarray[] = $results;
}

echo $resultarray[0];
echo $resultarray[1];

} else {
    header("Location: ../");
}

index.php:

    include("http://ift.tt/1IPwyQs".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 the file.php is being loaded fine as it gives me its output but when I try and use $resultarray[0]; it just doesnt work and say its undefined.

Any ideas on how I would resolve this pleasE?

Aucun commentaire:

Enregistrer un commentaire