array(2) {
[0]=>
string(1861) "{"2017_12_19_12_21_15":"27.94","2017_12_19_12_21_20":"27.93","2017_12_19_12_21_25":"27.95","2017_12_19_12_21_31":"27.95","2017_12_19_12_21_36":"27.93","2017_12_19_12_21_42":"27.94"}"
[1]=>
string(1861) "{"2017_12_19_12_21_14":"25.19","2017_12_19_12_21_20":"25.19","2017_12_19_12_21_25":"25.20","2017_12_19_12_21_31":"25.19","2017_12_19_12_21_36":"25.22","2017_12_19_12_21_41":"25.19"}"
}
答案 0 :(得分:0)
$sourceArray = [
'{"2017_12_19_12_21_15":"27.94","2017_12_19_12_21_20":"25.19","2017_12_19_12_21_25":"27.95","2017_12_19_12_21_31":"27.95","2017_12_19_12_21_36":"27.93","2017_12_19_12_21_42":"27.94"}',
'{"2017_12_19_12_21_14":"25.19","2017_12_19_12_21_20":"25.19","2017_12_19_12_21_25":"25.20","2017_12_19_12_21_31":"25.19","2017_12_19_12_21_36":"25.22","2017_12_19_12_21_41":"25.19"}',
];
# First you need to convert strings to arrays
$array = array_map(function ($element) {
return json_decode($element, true);
}, $sourceArray);
# Then find the same keys
$arraySameKeys = array_intersect(array_keys($array[0]), array_keys($array[1]));
var_dump($arraySameKeys);
# If it is necessary that the values are the same
$arraySameKeysValues = [];
foreach ($arraySameKeys as $key) {
if ($array[0][$key] === $array[1][$key]) {
$arraySameKeysValues[$key] = $array[0][$key];
}
}
var_dump($arraySameKeysValues);