Rita_Ruah Posted August 12, 2013 Share Posted August 12, 2013 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; Can you give me an example of php and other for JS? Thanks. Link to comment https://forums.phpfreaks.com/topic/281067-how-to-count-occurences/ Share on other sites More sharing options...
Rita_Ruah Posted August 13, 2013 Author Share Posted August 13, 2013 Bump Link to comment https://forums.phpfreaks.com/topic/281067-how-to-count-occurences/#findComment-1444733 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.