Hi all,
I'm at a dead-end here. I have a php file that I can query to return an array containing a bunch of data about a job listing. I include and query it by calling it like so within another file on my site.
Quick Notes:
The original file is in a different directory on my site than the page it's being included in.
I have tried returning the array at the end of the script.
I can print_r the array on the page I'm including the script on (so the URL path is correct).
If I go to this URL directly and print_r on the array, I see the entire array as expected. Also, if I include the file on page 2 like I did above with print_r on the array in the original file, I see the array printed out on page 2.
include 'http://www.example.com/php/job-details.php?job=jobname&city=thecity';
However, if I do not print_r on the array in the original file and just include it on page 2, I cannot do anything with it and the array variable isn't found.
Is this a case of variable scope? I'm so frustrated...
Here is the code I have in my original file:
<?
include('functions.php');
$jobtitlematch = $_GET["job"];
$jobcitymatch = $_GET["city"];
//echo $jobtitlematch;
//echo $jobcitymatch;
$url = 'http://somesite.com/something';
$xml = simplexml_load_file($url);
foreach($xml->job as $job) {
$jobtitle = makeURL((string)$job->title);
$jobcity = makeURL((string)$job->region);
if ($jobtitle == $jobtitlematch && $jobcity == $jobcitymatch) {
$jobdata[] = array(
Title => ((string)$job->title),
URL_Title => makeURL((string)$job->title),
Location => ((string)$job->region),
URL_Location => makeURL((string)$job->region),
Department => ((string)$job->department),
URL_Department => makeURL((string)$job->department),
Overview => ((string)$job->joboverview),
Responsibilities => ((string)$job->responsibilities),
Qualifications => ((string)$job->qualifications),
Keywords => ((string)$job->metakeywords)
);
}
return $jobdata;
//I have also tried return global $jobdata;
}
print_r($jobdata);
?>
Thanks in advance for any help you can provide...