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. Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/281067-how-to-count-occurences/#findComment-1444733 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.