как изменить значение ключа из строки в числовой из многомерного массива?(CodeIgniter) - PullRequest
0 голосов
/ 07 октября 2018

у меня есть многомерный массив.есть детали

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 ) )

я уже пробовал, но все равно не получилось.

1 Ответ

0 голосов
/ 07 октября 2018

Используя array_value, вы можете сбросить все ключи

<code>$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 "
"; выход;
...