# Retrieving XML Data using PHP

**URL:** <https://forum.kirupa.com/t/retrieving-xml-data-using-php/292272>\
**Category:** programming\
**Created:** [July 12, 2009, 3:52pm UTC](https://forum.kirupa.com/t/retrieving-xml-data-using-php/292272 "2009-07-12T15:52:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dreamerp](https://avatars.discourse-cdn.com/v4/letter/d/fbc32d/32.png) [@dreamerp](https://forum.kirupa.com/u/dreamerp)\
**Post date:** [July 12, 2009, 3:52pm UTC](https://forum.kirupa.com/t/retrieving-xml-data-using-php/292272/1 "2009-07-12T15:52:40Z")

</div>

Hello,

I have a PHP script that is using the eBay API. It makes the call and then returns XML data which then is retrieved using foreach in PHP.

However, I want it to select a random result and print this eBay listing. Do i do this with an array?

Because when I limit the returned results to one, it gives me the same result each time. It doesn’t randomly select one eBay listing. So, I thought I could return 50 results and then randomly choose one.

Could someone help me do this?

Thanks and hopefully i explained everything, just ask if I am missing something!
