020 555 1111
  • Old fashion, modular, procedural PHP plus some scaffolding techniques to allow it to mimic MVC simplicity.
  • A quick reference to help you find in PHP maze what needs to be done and how to do it.
  • Learn a PHP Object Oriented Programming by building a live discussion forum application.
  • MVC - Model View Controller - real life, easy reference and application.
This product has options, take a look at them and select ones you like the most.
Options are displayed under image section.
Top » XML

Create large XML using foreach and modulo
[XMLWriter example]

A nice idea to create large XML

$xmlWriter = new XMLWriter();
$xmlWriter->startDocument('1.0', 'UTF-8');
for ($i=0; $i<=100; ++$i) {
    $xmlWriter->startElement('message'); //top element
    $xmlWriter->writeElement('content', 'Example content'); //child element etc
    // Flush XML in memory to file every 1000 iterations
    //use modulo to force appending file every so often 
    //every 1000 iterations - in this example
    if (0 == $i%1000) { 
        file_put_contents('example.xml', $xmlWriter->flush(true), FILE_APPEND);

// Final flush to make sure we haven't missed anything
file_put_contents('example.xml', $xmlWriter->flush(true), FILE_APPEND);



    <content>Example content</content>