I have an array like this
[
1 => [
'name' => 123,
'id' => 105740727,
'email' => 'fghfhfh',
'phrases_relevant' => 123,
'searches_id' => 105740727,
],
2 => [
'name' => 'porshe',
'id' => 105713889,
'email' => 'fghfghf',
'phrases_relevant' => 'porshe',
'searches_id' => 105713889,
],
3 => [
'name' => 'porshe',
'id' => 105713889,
'email' => 'fghfghf',
'phrases_relevant' => 'merce',
'searches_id' => 105713889,
],
]
I need group this group via value. Output array should looks like below. dimension second and third has same searches_id
[0] => Array
(
[email] => fghfghf
[projects]=>
[porshe] => [porshe, merce]
[1] => ...
My code:
foreach ($results as $key => $result) {
$testArray[]['projects'][$result['name']][] = $result['phrases_relevant'];
but this insert one phrases.
phrases_relevantvalue123missing in your output? Your output example is very incomplete. Could you complete it for the given input?searches_id. So the columnsname,id,emailandphrases_relevantcan all vary when thesearches_idis the same? Or does only thephrases_relevantvary, as in your example?