0
Can someone help me by doing me the favor.
I have an array in this style:
$arrayTable = array(
0 => array(
'idApiUm' => 123,
'title' => 'Teste'
),
1 => array (
'idApiDois' => 765,
'title' => 'Título'
),
2 => array(
'idApiUm' => 632,
'title' => 'Nome'
),
3 => array(
'idApiDois' => 999,
'title' => 'Teste'
),
);
And I need to merge all arrays inside it that have the same value in 'title', and leave the key this way:
0 => array(
'idApiUm' => 123,
'idApiDois' => 999,
'title' => 'Teste'
),
Is it possible? I can’t solve this problem...
Carlos speaks, all right? First, thank you very much for the answer! So I got this result: Array ( [idApiUm] => 632 [title] => Test [idApiDois] => 999 ) However, note that the Apium ID is not showing the correct one, which should be 123...
– Lucas Martins
I MODIFIED THE CODE to arrive at the result you are looking for! Include below foreach a condition "if($x['title'] == 'Test')"
– Carlos Mesquita Aguiar
In this case it works perfectly, but I would like this condition to be achieved dynamically, and not just in the case of the title "Test"...
– Lucas Martins
In your case it is very specific! If only to recover the last value of each key would be simpler... But in the above case you want to recover the title value 'Test', so you need the validation of this key, otherwise I will hardly have precision in the result.
– Carlos Mesquita Aguiar
Yes, it’s very complicated! But I think that Virgilio, from the other answer, managed to solve it! Anyway, thank you very much for helping Carlos!!!!
– Lucas Martins