holyearth Posted December 11, 2006 Share Posted December 11, 2006 I am parsing an XML file where the following situation is ocurringThe data in the XML file has a certain variable called:<ImageUrlMedium>http://images.amazon.com/images/P/B0006ISHT2.01.MZZZZZZZ.jpg</ImageUrlMedium>But, the entire XML file has several different <ImageUrlMedium> for example here's another:<ImageUrlMedium>http://images.amazon.com/images/P/B00004R7IE.01.MZZZZZZZ.jpg</ImageUrlMedium>I have made an array, but when I print ImageUrlMedium, it's showing ALL of the ImageUrlMedium'sI want it to show only the first 5 (or 6 or 7) ImageUrlMedium's from the array ... not all of them from the array .......Is there a way to "call" upon the array to only show the first X amount?Thanks in advance, sorry if I have confused anyone. Link to comment https://forums.phpfreaks.com/topic/30194-xml-parsing/ Share on other sites More sharing options...
drifter Posted December 11, 2006 Share Posted December 11, 2006 well for only a field or two out of a large XML, sometimes I use preg_match. But if you have php 5, you can use the simpleXML - very cool - if you are going to do a lot with XML and are on php 4 - consider upgrading - it is worth it in my opinion Link to comment https://forums.phpfreaks.com/topic/30194-xml-parsing/#findComment-138812 Share on other sites More sharing options...
holyearth Posted December 11, 2006 Author Share Posted December 11, 2006 ff Link to comment https://forums.phpfreaks.com/topic/30194-xml-parsing/#findComment-139012 Share on other sites More sharing options...
HuggieBear Posted December 11, 2006 Share Posted December 11, 2006 Why not use a loop? Assuming your array is keyed by number, something like this would work...[code]<?php$i = 0;while ($i < 5){ // enter the amount that you want to do something with here echo $arrayname[$i]; // do what you want with the array, echo for example $i++; // increment the counter by 1.}?>[/code]RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/30194-xml-parsing/#findComment-139015 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.