I use XML import for my website. The main problem is the execution time and the limit enforced by my server. Because of that I want to split XML import into segments. My script looks so far in this way:
$xml = simplexml_load_file('test.xml');
foreach ($xml->products as $products) {
...
}
The question is how can I start foreach command from specific moment, e.g. foreach could start from 100. I know it can be done in this way below, but is there any easier way?
$n=0;
foreach ($xml->products as $products) {
$n++;
if ($n>99) { //do something }
else { //skip }
}
Just use a for loop, than you can specify the range you want to loop over