🥹Remove duplicates from a 2-dimensional array by duplicate value keeping the last element intact (ok)
https://onlinephp.io/code/64e035855d8a69d977a8d6a9b87769040ca85752
Loại bỏ các bản sao khỏi mảng 2 chiều theo giá trị trùng lặp giữ nguyên phần tử cuối cùng
<!DOCTYPE html>
<html>
<body>
<pre>
<?php
$data = [
[
'list_id' => 86,
'list_reference' => 130948,
'list_title' => 'Offer: apartment 2+kk',
'list_city' => 'Prague',
'list_date' => '2017-03-03 11:20:35',
'list_status' => 0,
'list_creator' => 'Company A',
'list_price' => 30000,
'list_furniture' => ["1","0","0"],
'list_accommodation' => 'flat',
],
[
'list_id' => 87,
'list_reference' => 130947,
'list_title' => 'Offer: apartment 2+kk',
'list_date' => '2017-03-03 11:20:35',
'list_status' => 0,
'list_creator' => 'Company B',
'list_price' => 30000,
'list_furniture' => ["1","0","0"],
'list_accommodation' => 'flat'
],
[
'list_id' => 88,
'list_reference' => 130947,
'list_title' => 'Offer: apartment 3+kk',
'list_date' => '2017-03-03 11:20:35',
'list_status' => 0,
'list_creator' => 'Company B',
'list_price' => 30000,
'list_furniture' => ["1","0","0"],
'list_accommodation' => 'flat'
]
];
// Reverse array, so the first occurance keeped.
$data = array_reverse($data);
$result = array_reverse( // Reverse array to the initial order.
array_values( // Get rid of string keys (make array indexed again).
array_combine( // Create array taking keys from column and values from the base array.
array_column($data, 'list_title'),
$data
)
)
);
var_export($result);
?>
</pre>
</body>
</html>

PreviousHướng dẫn sử dụng ionCube Encoder để mã hóa code (ok)NextTrả về một mảng tên tệp hoặc thư mục khớp với mẫu đã chỉ định (ok)
Last updated
Was this helpful?