RaythMistwalker Posted March 10, 2010 Share Posted March 10, 2010 Ok atm im running a competition thing that involves song artists. Basically each person is to send me a list of song artists. They get 2 Points for each artist but if they do a double they get -5 Points. I need a form calculator that i copy/paste the song list into an editbox. The artists could be separated by new lines OR commas (,) First i want it to check for any duplicates then for each duplicate found give -5 points (start at 0). Then i want it to count the number of artists and give 2 for each and add it on and finally display the total to me. Link to comment https://forums.phpfreaks.com/topic/194797-kinda-a-calculator-thingy-but/ Share on other sites More sharing options...
gwolgamott Posted March 10, 2010 Share Posted March 10, 2010 Sounds like a fun project. Are you stuck somewhere? I'd think the way to start this is for a script to the form data string, explode it or split it depending on your delimiting uses. Then do an array count multiply that by 2 for each element. Then I'd use a double loop that would go through the array and with each element have the second loop go through the array comparing that element to every element in the array. If more then one match (since there will always be at least one match counting itself) add the negative 7 to each one(-5 plus -2 to get rid of the 2 points we added for that element already ealier). I think that'd do what you wanted to do, only reason I do the points different is preference in how I would set the code up. Doesn't matter what you do first and this can be more proficient too, but quick and dirty first thoughts is all. Link to comment https://forums.phpfreaks.com/topic/194797-kinda-a-calculator-thingy-but/#findComment-1024334 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.