Hi there,
I'am developing a snippet for a website widget that will read/fetch data from an XML file, sort it in array's and then show it back to the user - formated as a sentence.
Example:
XML sample:
<row id="1">
<username>GGR1024</username>
<name>Raymond</name>
<surname>Saliba</surname>
<game>Lotto</game>
<won>5000</won>
</row>
<row id="2">
<username>GGR1111</username>
<name>Isabelle</name>
<surname>Bonnici</surname>
<game>Lotto</game>
<won>1000</won>
</row>
<row id="3">
<username>GGR1024</username>
<name>Raymond</name>
<surname>Saliba</surname>
<game>Lotto</game>
<won>2000</won>
</row>
<row id="4">
<username>GGR1024</username>
<name>Raymond</name>
<surname>Saliba</surname>
<game>Lotto</game>
<won>200</won>
</row>
So... I read that XML file line by line and put the values in an array, do some functions and then show the formatted data back to the user:
Formatted data example:
Raymond Saliba won $5000 from Lotto
Isabelle Bonnici won $1000 from Lotto
Raymond Saliba won $2000 from Lotto
Raymond Saliba won $200 from Lotto
(notice that 'Raymond Saliba' appears 3 times in this example)
now the problem is this -> I need to only show 'Raymond Saliba' once to the user (each person is unique by his username) and the string that I show to the user must be the one that contains the highest ammount won.
Proper output Example:
Raymond Saliba won $5000 from Lotto
Isabelle Bonnici won $1000 from Lotto
So the blueprint behind my explenation is something like this:
Person 1 ------> $5000
$2000
$200
Person 2 ------> $1000
(each person can have alot of values, and I need to show that user with the highest value - ONCE)
Sounds easy right ? -> not for me... I'am not a professional developer with PHP but I tend to get along just fine, I have tried various methods for this snippet but so far I didn't find any luck :(
I tried multidimensional arrays, array_unique, and some sorting functions but all ended with no luck at all...
Can someone that understands what I need give me some advice/help please ? preferably with example code using the sample data that I gave to you in this post (because it makes me understand it better, sometimes I'm a slow learner sorry)
Thank you very much and I'm awaiting your reply :)
Raymond Saliba