根据数组中的数据在另一个数组中创建数组

时间:2018-12-06 14:52:46

标签: arrays arraylist multidimensional-array

这是我的代码,根据这些数据(1324、1325、1326)应该显示,我想要这样的内容。如何获得这些类型的数组?我想要这样的东西,根据这些数据(1324、1325、1326)应该显示出来。如何获得这些类型的数组?

foreach ( $insurerlist as $val ) {
            if (array_key_exists ( $val[2], $_placemetdatalist)) {
                array_push($_placemetdatalist, $val[2], $val[22], $val[5], $val[6], $val[7], $val[12], $val[13], $val[24]);
            } else {
                $_placemetdatalist[] = array([$val[2], $val[22], $val[5], $val[6], $val[7], $val[12], $val[13], $val[24]]);
            }
        }

我正在获取的这类数据

array (size=6)
  0 => 
    array (size=1)
      0 => 
        array (size=8)
          0 => string '1324' (length=4)
          1 => string 'AAAAAAAA' (length=8)
          2 => string '50.00' (length=5)
          3 => string '500000.00' (length=9)
          4 => string '10.00' (length=5)
          5 => string '50000.00' (length=8)
          6 => string 'Self' (length=4)
          7 => string 'dsfdsfdsfdsf' (length=12)
  1 => 
    array (size=1)
      0 => 
        array (size=8)
          0 => string '1324' (length=4)
          1 => string 'Demo113555' (length=10)
          2 => string '50.00' (length=5)
          3 => string '500000.00' (length=9)
          4 => string '10.00' (length=5)
          5 => string '50000.00' (length=8)
          6 => string 'Self' (length=4)
          7 => string 'qwer' (length=4)
  2 => 
    array (size=1)
      0 => 
        array (size=8)
          0 => string '1325' (length=4)
          1 => string 'kamini' (length=6)
          2 => string '50.00' (length=5)
          3 => string '50000.00' (length=8)
          4 => string '5.00' (length=4)
          5 => string '2500.00' (length=7)
          6 => string 'Lead' (length=4)
          7 => string 'webdev' (length=6)

我想要这样的东西,根据这些数据(1324、1325、1326)应该显示出来。如何获得这些类型的数组?

array (size=6)
      0 => 
        array (size=1)
          0 => 
            array (size=8)
              0 => string '1324' (length=4)
              1 => string 'AAAAAAAA' (length=8)
              2 => string '50.00' (length=5)
              3 => string '500000.00' (length=9)
              4 => string '10.00' (length=5)
              5 => string '50000.00' (length=8)
              6 => string 'Self' (length=4)
              7 => string 'dsfdsfdsfdsf' (length=12)
          1 => 
            array (size=8)
              0 => string '1324' (length=4)
              1 => string 'Demo113555' (length=10)
              2 => string '50.00' (length=5)
              3 => string '500000.00' (length=9)
              4 => string '10.00' (length=5)
              5 => string '50000.00' (length=8)
              6 => string 'Self' (length=4)
              7 => string 'qwer' (length=4)
      1 => 
        array (size=1)
          0 => 
            array (size=8)
              0 => string '1325' (length=4)
              1 => string 'kamini' (length=6)
              2 => string '50.00' (length=5)
              3 => string '50000.00' (length=8)
              4 => string '5.00' (length=4)
              5 => string '2500.00' (length=7)
              6 => string 'Lead' (length=4)
              7 => string 'webdev' (length=6)
          1 => 
            array (size=8)
              0 => string '1325' (length=4)
              1 => string '"Royal Sundaram General Insurance Co Ltd"'
              2 => string '50.00' (length=5)
              3 => string '50000.00' (length=8)
              4 => string '5.00' (length=4)
              5 => string '2500.00' (length=7)
              6 => string 'Lead' (length=4)
              7 => string 'test1' (length=5)

0 个答案:

没有答案