I have an simple array like this.
array:4[
0 => array:3 [
'customerName' => "John Dunk"
'customerPhone' => 5555555555
'Difference' => 125.0
]
1=> array:3 [
'customerName' => "John Dunk"
'customerPhone' => 5555555555
'Difference' => 192.0
]
2=> array:3 [
'customerName' => "James Morle"
'customerPhone' => 111111111
'Difference' => 145.0
]
3=> array:3 [
'customerName' => "James Morle"
'customerPhone' => 111111111
'Difference' => 114.0
]
]
But I want to make that array like this one.
array:2[
0 => array:3 [
'customerName' => "John Dunk"
'customerPhone' => 5555555555
'Difference' => 125.0
]
1=> array:3 [
'customerName' => "James Morle"
'customerPhone' => 111111111
'Difference' => 114.0
]
]
So as you understand:
If inside of multidimensional array 2 or more array has SAME "customerName", choose the smallest "Difference" one and delete the other arrays.
If you can't understand you can look my example.
Everytime the smallest "Difference" index is going to stay, if 2 or more array has SAME "customerName" We are going to look that arrays and search for the smallest, when we found that array, we will delete the other ones.
I couldn't code this for hours. If anybody can help, I will be very happy realy.
Thanks