Jump to content

XML Parsing


holyearth

Recommended Posts

I am parsing an XML file where the following situation is ocurring

The 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's

I 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

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]

Regards
Huggie
Link to comment
https://forums.phpfreaks.com/topic/30194-xml-parsing/#findComment-139015
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.