I have 1 field for each users which gives me a series of skills:
$user->user_description
User 1 = Geography, English, Math, Science
User 2 = English, Math, Geography
User 3 = French, Math
NOTE Each one is a phrase with comma separated strings
Then I have another field for the gender which for each user I get:
get_user_meta( $the_user_id, $gender, $single );
User 1 = Male
User 2 = Female
User 3 = Male
The output I am looking for is:
- We have 2 Math teachers with gender male
- We have 2 Geography teachers with gender male and female
- We have 1 French teacher with gender female
- We have 2 English teacher with gender male and female
- We have 1 Science teacher with gender male
This is how I loop the users:
$blogusers = get_users( 'orderby=nicename&role=author' );
foreach ( $blogusers as $user ) {
NOTE
I tried to simplify on here but I went much further up with the code which I have it in another question. Any other info you may need I am ready to provide it, it is really getting me stack. The main bit which blocks me is how to associate the Gender together with each skills once these have been splitted and counted.
What I have managed to do:
- Split the comma separated list and push them into an array
- Check for duplicated words in the array in order to be able to achieve the number of each skill e.g. 2 English
- Be able to have the tot. number of each gender
But yet, not be able to add the gender for each skill once splitted