I am creating a simple application. This is the user interface to the online ordering system.
In principle, the system will work as follows:
Other companies upload their orders to our FTP server. These orders are simple XML files (containing things like customer data, address information, ordered products and quantities ...)
I created a simple user interface in HTML5, jQuery and CSS - everything works in PHP.
PHP reads the contents of the order (using the built-in SimpleXML functions) and displays it on the web page.
So, this is a web application that should always work in a browser in the office. The PHP application will display the contents of all orders. Every fifteen minutes or so, the app checks for new orders.
How do I iterate over all XML files in a directory?
Now my application can read the contents of one XML file and display it on the page.
My current code is as follows:
$xml_file = file_get_contents("Order/6366246.xml",FILE_TEXT);
$xml = new SimpleXMLElement($xml_file);
echo $xml->OrderHead->ShopPO;
echo "<ul>";
foreach ($xml->OrderLines->OrderLine as $orderline) {
"<li>".$orderline->Quantity." st.</li>\n".
"<li>".$orderline->SKU."</li>\n";
}
echo "</ul>";
So this is my code. Pretty simple. Only one thing is needed: print the contents of all the order files on the screen so that my colleagues and I can see the order, confirm it and deliver it.
What is it.
But right now - as you can see - I am choosing one order at a time, located in the Order directory. But how can I go through the entire catalog of orders and read a and display the contents of each order (for example, above)?
I am stuck. I really don't know how you get all the (xml) files in the directory, and then do something with the files (for example, read them and the echo data as I want).
- > . PHP/, , , .
!
// ( )