如何将键值从字符串更改为多维数组的数字? (代码点火器)
how to change keys value from string to numeric of a multidimentional array? (codeigniter)
我有一个多维数组。有详情
Array ( [0] => Array ( [score] => 2 [idks] => 3 [pasm] => 2 [qty] => 2 [qility] => 3 [point] => 2 [cls] => 5 [org] => 5 [outd] => 5 ) [1] => Array ( [score] => 5 [idks] => 4 [pasm] => 3 [qty] => 3 [qility] => 5 [point] => 3 [cls] => 5 [org] => 5 [outd] => 5 ) [2] => Array ( [score] => 3 [idks] => 2 [pasm] => 3 [qty] => 1 [qility] => 3 [point] => 1 [cls] => 4 [org] => 1 [outd] => 5 ) )
我需要把键值改成int,像这样
Array ( [0] => Array ( [0] => 2 [1] => 3 [2] => 2 [3] => 2 [4] => 3 [5] => 2 [6] => 5 [7] => 5 [8] => 5 ) [1] => Array ( [0] => 5 [1] => 4 [2] => 3 [3] => 3 [4] => 5 [5] => 3 [6] => 5 [7] => 5 [8] => 5 ) [2] => Array ( [0] => 3 [1] => 2 [2] => 3 [3] => 1 [4] => 3 [5] => 1 [6] => 4 [7] => 1 [8] => 5 ) )
我已经试过了,但还是失败了。
通过使用array_value您可以重置所有键
$arr = Array ( '0' =>
Array ( 'score' => 2, 'idks' => 3, 'pasm' => 2, 'qty' => 2, 'qility' => 3, 'point' => 2, 'cls' => 5, 'org' => 5, 'outd' => 5),
'1' => Array ( 'score' => 5, 'idks' => 4, 'pasm' => 3, 'qty' => 3, 'qility' => 5, 'point' => 3, 'cls' => 5, 'org' => 5, 'outd' => 5 ),
'2' => Array ( 'score' => 3, 'idks' => 2, 'pasm' => 3, 'qty' => 1, 'qility' => 3, 'point' => 1, 'cls' => 4, 'org' => 1, 'outd' => 5 ) );
$arr = array_map('array_values', $arr);
echo "<pre>";
print_r($arr);
echo "</pre>";
exit;
我有一个多维数组。有详情
Array ( [0] => Array ( [score] => 2 [idks] => 3 [pasm] => 2 [qty] => 2 [qility] => 3 [point] => 2 [cls] => 5 [org] => 5 [outd] => 5 ) [1] => Array ( [score] => 5 [idks] => 4 [pasm] => 3 [qty] => 3 [qility] => 5 [point] => 3 [cls] => 5 [org] => 5 [outd] => 5 ) [2] => Array ( [score] => 3 [idks] => 2 [pasm] => 3 [qty] => 1 [qility] => 3 [point] => 1 [cls] => 4 [org] => 1 [outd] => 5 ) )
我需要把键值改成int,像这样
Array ( [0] => Array ( [0] => 2 [1] => 3 [2] => 2 [3] => 2 [4] => 3 [5] => 2 [6] => 5 [7] => 5 [8] => 5 ) [1] => Array ( [0] => 5 [1] => 4 [2] => 3 [3] => 3 [4] => 5 [5] => 3 [6] => 5 [7] => 5 [8] => 5 ) [2] => Array ( [0] => 3 [1] => 2 [2] => 3 [3] => 1 [4] => 3 [5] => 1 [6] => 4 [7] => 1 [8] => 5 ) )
我已经试过了,但还是失败了。
通过使用array_value您可以重置所有键
$arr = Array ( '0' =>
Array ( 'score' => 2, 'idks' => 3, 'pasm' => 2, 'qty' => 2, 'qility' => 3, 'point' => 2, 'cls' => 5, 'org' => 5, 'outd' => 5),
'1' => Array ( 'score' => 5, 'idks' => 4, 'pasm' => 3, 'qty' => 3, 'qility' => 5, 'point' => 3, 'cls' => 5, 'org' => 5, 'outd' => 5 ),
'2' => Array ( 'score' => 3, 'idks' => 2, 'pasm' => 3, 'qty' => 1, 'qility' => 3, 'point' => 1, 'cls' => 4, 'org' => 1, 'outd' => 5 ) );
$arr = array_map('array_values', $arr);
echo "<pre>";
print_r($arr);
echo "</pre>";
exit;