A week or 2 ago, NogDog assisted on some perfect coding that I was struggling to figure out Thread here :
$types = array();
foreach($flower[1] as $type)
{
$types[$type] += 1;
}
echo "<pre>";
print_r($types);
echo "</pre>\n";
This worked great for counting the like items and I can echo out the new array details as planned. But then I had to go and want to get a bit more complex.
Instead of just having 1 value to determine count, now i have 2. Using the prior example:
Array
(
[0] => Array
(
[0] => She likes Bob's lilacs!
[1] => She likes David's lilacs!
[2] => She likes Bob's carnations!
[3] => She likes David's lilacs!
[4] => She likes Mark's roses!
[5] => She likes Mark's carnations!
[6] => She likes Bob's daisies!
[7] => She likes Andy's daisies!
[8] => She likes Ed's lilacs!
[9] => She likes Anton's lillies!
[10] => She likes Jeremy's lillies!
)
[1] => Array
(
[0] => Bob's
[1] => David's
[2] => Bob's
[3] => David's
[4] => Mark's
[5] => Mark's
[6] => Bob's
[7] => Andy's
[8] => Ed's
[9] => Anton's
[10] => Jeremy's
)
[2] => Array
(
[0] => lilacs
[1] => lilacs
[2] => carnations
[3] => lilacs
[4] => roses
[5] => carnations
[6] => daisies
[7] => daisies
[8] => lilacs
[9] => lillies
[10] => lillies
)
the ($key as $value) will work if I wanted to count Names or flowers - but I can not find information on if want $key to be determined by name AND flower, ie: have output to end up like:
Bob's lilacs: 1
David's lilacs: 2
Bob's Carnations: 1
Mark's Roses: 1
Mark's Carnations: 1
Bob's Daisies: 1
Andy's daisies: 1
Ed's lilac's: 1
Anton's Lillies: 1
Jeremy's lillies: 1
where both name and flower are they key, but separate variables. Hope this makes sense and someone can point me in the right direction again.
tia!