Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Count and register ocurrences

$
0
0

Hello, I have a programming doubt... I think this can apply to every language, imagine this scenario where I have this xml:

 

<MediaFiles>
<MediaFile>
   <![CDATA[VIDEO]]>
</MediaFile>
<MediaFile>
   <![CDATA[VIDEO]]>
</MediaFile>
<MediaFile>
   <![CDATA[VIDEO]]>
</MediaFile>
<MediaFile>
   <![CDATA[VIDEO]]>
</MediaFile>
<MediaFile>
   <![CDATA[VIDEO]]>
</MediaFile>
</MediaFiles>
 
How can I count the number of occurences of <MediaFile> so I can make a group of every mediafile and do a Random to select one of them?
 
Pseudo-code of what I want:
 
foreach(<mediafile> of <mediafiles>)
array[] = mediafile VIDEO;

Viewing all articles
Browse latest Browse all 13200

Trending Articles