PHP question

Associate
Joined
2 Sep 2007
Posts
1,975
Hi All

I'm trying to pull a specific element in an XML file and I want to use a variable in the following code: -

echo $episodes->episode[0]->title;

0 pulls the first one. I want to use a variable instead I've tried this

echo $episodes->episode[$index]->title;

But I've had no joy. Any ideas?
 
Associate
OP
Joined
2 Sep 2007
Posts
1,975
But if I do the following I can't get anything out (BTW I am passing a parameter via the querystring): -

<?php

$index = $_GET['id'];
echo intval($index);

echo $episodes->episode[$index]->title; ?></p>
 
Back
Top Bottom