Busque valores duplicados en una matriz asociativa y agréguelos a un recuento
Hola, estoy tratando de contar el número de valores duplicados en una matriz asociativa que se ve así:
array(3) { [0]=> array(3) { ["Title"]=> string(25) "hello"
["Price"]=> int(50)
["Count"]=> int(1) }
[1]=> array(3) { ["Title"]=> string(35) "world"
["Price"]=> int(50)
["Count"]=> int(1) }
[2]=> array(3) { ["Title"]=> string(25) "hello"
["Price"]=> int(50)
["Count"]=> int(1) } }
Como puede ver aquí, hay un valor duplicado en la etiqueta "Título". Quiero contarlos y agregar uno a la parte "Recuento". Comencé a hacer algo como esto:
$prodArray = array();
// Add the values to the array if it's the first time it occurs.
if (!in_array($row['prodTitle'], $prodArray["Title"]))
{
array_push($prodArray,
array( Title => $row['prodTitle'],
Price => $row['prodPrice'],
Count => 1)
);
}
else
{
//Add one to the count for the current item.
}
la cosa es que no puedo acceder al elemento "Título" en la matriz a través de la función in_array. Cualquier sugerencia es bienvenida.