Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.