I've been teaching myself PHP this last week so that I can write my own web apps (character builders and the like). It's coming along well, but I've run into a block. I'm hoping that one of the many clever people on EN World can help me!
So....
I have an array:
skill[1]
skill[2]
skill[3]
... all the way to skill[13]
In each slot, there is the name of a skill, such as running, or stealth, or computers, or herbalism, etc.
The problem is that some slots will be duplicated. For example, the user may have selected herbalism three items during the character creation process, so three of those 13 slots are "herbalism".
What I need is a list of skills, and the number of times they've been taken. So rather than:
1. running
2. herbalism
3. jumping
4. computers
5. running
6. running
7. chess
8. woodworking
9. dodging
10. dodging
11. computers
12. swords
13. bows
I need:
1. running 3
2. dodging 2
3. computers 2
4. herbalism 1
5. chess 1
6. woodworking 1
7. swords 1
8. bows 1
9. jumping 1
So I need some kind of function to take that first list and turn it into the second list.
I know there's an array_count_values function in PHP, and I can get it to split out those values on the screen, but I don't know how to "work" with those values to put them into some kind of new array I can use.
Anybody got any ideas? Does that even make sense?
So....
I have an array:
skill[1]
skill[2]
skill[3]
... all the way to skill[13]
In each slot, there is the name of a skill, such as running, or stealth, or computers, or herbalism, etc.
The problem is that some slots will be duplicated. For example, the user may have selected herbalism three items during the character creation process, so three of those 13 slots are "herbalism".
What I need is a list of skills, and the number of times they've been taken. So rather than:
1. running
2. herbalism
3. jumping
4. computers
5. running
6. running
7. chess
8. woodworking
9. dodging
10. dodging
11. computers
12. swords
13. bows
I need:
1. running 3
2. dodging 2
3. computers 2
4. herbalism 1
5. chess 1
6. woodworking 1
7. swords 1
8. bows 1
9. jumping 1
So I need some kind of function to take that first list and turn it into the second list.
I know there's an array_count_values function in PHP, and I can get it to split out those values on the screen, but I don't know how to "work" with those values to put them into some kind of new array I can use.
Anybody got any ideas? Does that even make sense?