I have a a vaery large array which is parsed to my php script in json form. I would like to convert the keys from string to integer. The keys are serial numbers so i can't just use array_values. Currently i do it like this but would much prefer a solution that didn't involve a loop.
Example Array after json decode before int conversion:
array (
'123' => 'my text',
'223' => 'my text too',
'183' => 'my text foo',
'103' => 'my text doo',
// more array items
);
Example Code:
$data = json_decode($_POST['json']);
$newArr = Array();
foreach ($data as $key => $val) {
$ref = (int)$key;
newArr[$ref] = $key;
}