Php 8.2.25 на x86_64. PrettyPrint-Override ">
Код: Выделить всё
// build superset array
$arOne = [
"cat" => ["meow", "cat is hungry"],
"dog" => ["woof", "dog is concerned"],
"bird" => ["chirp", "bird is happy"],
];
// specify subset keys to look for
$arTwo = array_flip( ["dog", "bird"] );
// get a subset array,
// by finding the keys that match in the superset array
$arDirect = array_intersect_key( $arOne, $arTwo );
// store our superset array into APCU
apcu_store("animals",$arOne,60000);
// get a copy of our superset array, from APCU
$arOneFetch = apcu_fetch("animals");
// get a second subset array,
// by finding the keys that match in the copy of our superset array
$arFetch = array_intersect_key( $arOneFetch, $arTwo );
< /code>
Результаты: < /p>
count($arOne) is: 3 / JSON Text: {"cat":["meow","cat is hungry"],"dog":["woof","dog is concerned"],"bird":["chirp","bird is happy"]}
count($arOneFetch) is: 3 / JSON Text: {"cat":["meow","cat is hungry"],"dog":["woof","dog is concerned"],"bird":["chirp","bird is happy"]}
count($arDirect) is: 2 / JSON Text: {"dog":["woof","dog is concerned"],"bird":["chirp","bird is happy"]}
count($arFetch) is: 0 / JSON Text: [] //
var_dump ($ arone): < /p>
array (size=3)
'cat' =>
array (size=2)
0 => string 'meow' (length=4)
1 => string 'cat is hungry' (length=13)
'dog' =>
array (size=2)
0 => string 'woof' (length=4)
1 => string 'dog is concerned' (length=16)
'bird' =>
array (size=2)
0 => string 'chirp' (length=5)
1 => string 'bird is happy' (length=13)
< /code>
var_dump ($ aronefetch): < /p>
array (size=3)
'cat' =>
array (size=2)
0 => string 'meow' (length=4)
1 => string 'cat is hungry' (length=13)
'dog' =>
array (size=2)
0 => string 'woof' (length=4)
1 => string 'dog is concerned' (length=16)
'bird' =>
array (size=2)
0 => string 'chirp' (length=5)
1 => string 'bird is happy' (length=13)
Подробнее здесь: https://stackoverflow.com/questions/795 ... ng-problem