php - 如何防止 array_push 中出现重复键

标签 php arrays key array-push

我有 2 个 2D 数组,如何获取唯一的键并只推送这些键?例如:

$array = json_decode('[{"7654321":1368356071},{"1234567":1368356071}]',true);
$array2 = array(array(1234567 => time()), array(7654321 => time()), array(2345678 => time()));
//array_push($array, $array2[2]); 

-- 如何动态获取像本例中的 $array2[2] 这样的唯一键?

最佳答案

为什么不在 php 中使用 array_unique() 函数? http://php.net/manual/ru/function.array-unique.php

关于php - 如何防止 array_push 中出现重复键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16507719/

相关文章:

php - 使用 CloudFlare 和 OpenShift 以及 WordPress 应用程序的重定向循环

php - if_POST then 执行一个或多个命令

mysql - SQL 添加外键到现有表

compact-framework - 另一个应用程序可以使用 RSACryptoServiceProvider 访问存储在 key 容器中的私钥吗?

php - 从州代码获取发货州的名称,或者如果用户在 WooCommerce 中键入该名称

php - 克隆一个可拖动的 div

arrays - 查找分组在数组中的特定零点 - matlab

PHP 将字符串矩阵转换为多维数组

c - 如何使用 C 中的 offsetof() 和指针在结构中填充数组

JavaScript : mapping same key to different arrays