PHP and SimpleXML - Can't Output File Contents

617

Thanks in advance for the help...

I'm trying to use SimpleXML to output the contents of one of my files. In order to find the file, I had to scan a directory, split the contents of a folder up into two arrays, and then select the newest file from one of the arrays.

$files = scandir($dir);
$roster = [];
$schedule = [];
foreach ($files as $file) {
    if (!(strpos($file, 'roster')===false)) {
        $roster<< $file;
    } else {
        $schedule<< $file;
    }
}

Now when I try to use SimpleXML, I can't get anything to show up.

 $xml_file = $file;
 $xml = simplexml_load_file($xml_file);

(At this point I try to output the information using echo, but no luck.)

Do I need to open and close the file, or is there another crucial step I'm missing?

People are also looking for solutions to the problem: php - Remove the space between two words

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.