按列或键拆分多维数组[重复]

问题描述 投票:0回答:0

我有这样的数组:

Array (
      [0] => Array (
                [distance] => 65511.557098598 [kelas] => kecimen [id_training] => 1 [id_testing] => 1 )
      [1] => Array (
                [distance] => 48474.532926996 [kelas] => kecimen [id_training] => 2 [id_testing] => 1 )
      [2] => Array (
                [distance] => 9300.7615233908 [kelas] => kecimen [id_training] => 1 [id_testing] => 2 )
      [3] => Array (
                [distance] => 26322.112844992 [kelas] => kecimen [id_training] => 2 [id_testing] => 2 )
)

我想通过 id_testing 将它们拆分成新的数组,像这样:

Array (
      [0] => Array (
                [distance] => 65511.557098598 [kelas] => kecimen [id_training] => 1 [id_testing] => 1 )
      [1] => Array (
                [distance] => 48474.532926996 [kelas] => kecimen [id_training] => 2 [id_testing] => 1 )
      )

Array (
      [0] => Array (
                [distance] => 9300.7615233908 [kelas] => kecimen [id_training] => 1 [id_testing] => 2 )
      [1] => Array (
                [distance] => 26322.112844992 [kelas] => kecimen [id_training] => 2 [id_testing] => 2 )
      )

谁能告诉我怎么做?非常感谢。

php codeigniter multidimensional-array split codeigniter-4
© www.soinside.com 2019 - 2024. All rights reserved.