My database outputs a list of topics, but array_column()
casts the numeric strings to integers, so my array is no more consistent:
$list = [
[
'k' => '1967',
'v' => '1967 v',
],
[
'k' => '1939-1945',
'v' => '1939-1945 v',
],
];
$list = array_column($list, 'v', 'k');
$result = [];
foreach ($list as $k => $v) {
$result[] = [$k => gettype($k), $v => gettype($v)];
}
print_r($result);
So the result is:
Array
(
[0] => Array
(
[1967] => integer
[1967 v] => string
)
[1] => Array
(
[1939-1945] => string
[1939-1945 v] => string
)
)
How to avoid the automatic casting of the string "1967" in a simple way?