array_unique multidimensional php
<?php
function super_unique($array,$key)
{
$temp_array = [];
foreach ($array as &$v) {
if (!isset($temp_array[$v[$key]]))
$temp_array[$v[$key]] =& $v;
}
$array = array_values($temp_array);
return $array;
}
$arr="";
$arr[0]['id']=0;
$arr[0]['titel']="ABC";
$arr[1]['id']=1;
$arr[1]['titel']="DEF";
$arr[2]['id']=2;
$arr[2]['titel']="ABC";
$arr[3]['id']=3;
$arr[3]['titel']="XYZ";
echo "<pre>";
print_r($arr);
echo "unique*********************<br/>";
print_r(super_unique($arr,'titel'));
?>
Array
(
[0] => Array
(
[id] => 1
[value] => 111
)
[1] => Array
(
[id] => 2
[value] => 222
)
[2] => Array
(
[id] => 3
[value] => 333
)
[3] => Array
(
[id] => 1
[value] => 111
)
)
$uniquePids = array_unique(array_map(function ($i) { return $i['pid']; }, $holder));
Also in PHP:
- [WAR] 70 (lib\peer.php:164) file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
- current date timestamp in php
- detect mouse click javascript
- Builder::unique() laravel
- all seed run in laravel\
- array_key_exists(
- fgets in php ommit new line
- @lang laravel blade
- $_SERVER php where link came from
- check word is in string php
- console data from php to jquery console
- add code return block phpstorm
- check array key exists not in array php
- codeigniter get last inserted id with where condition
- explode in php
- date time function to php date
- all files in a folder to array php
- PHP Numbers
- add 1 day to date
- base64 to image
- find string contain spacific charactor or not in php
- enable php error output
- check what type variable it is php
- Call to a function trim() on string laravel