hinchcliffe Posted February 9, 2010 Share Posted February 9, 2010 Hello, I'm currently grabbing data from an XML feed & with this data I'm updating product information in our database. We have over 2500+ products in our database. I'm trying to run a script that will go through and update every products price from the xml feed. My issue is that the xml feed only allows you to pull 50 products at once. So this is where I'm stuck. Right now I have a for each statement that limits to grabbing 50 products. <?php $i = 0; foreach ($products as &$value) { //product update code goes in here if (++$it == 50) break; } ?> Is there anyway I can continue where I left off and pull the next 50 products to update? I'm kind of lost. Link to comment https://forums.phpfreaks.com/topic/191431-need-help-for-each-xml-please-read/ Share on other sites More sharing options...
RussellReal Posted February 9, 2010 Share Posted February 9, 2010 function next50($page) { // this code assumes the xml feed will return no data when there is no more rows to update.. // get the other 50 and fill into $xml with $page being an int if ($xml == null) return; foreach ($xml as $v) { // parse your XML into $id, $price, $name etc $products[$id] = "whatever whatever"; } next50(++$page); } next50(1); note its untested, but it should work. Link to comment https://forums.phpfreaks.com/topic/191431-need-help-for-each-xml-please-read/#findComment-1009327 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.