如何从主数组php中的两个数组获取值

时间:2018-10-23 08:04:58

标签: arrays

我有一个称为数据的主数组,其中包含3个数组,每个数组都包含多个这样的数组

0 => array:2 [
    0 => array:5 [
      "name" => "user1"
      "description" => "user description"
    ]
    1 => array:5 [
      "name" => "user2"
      "description" => "user description 2"
    ]
  ]
  1 => array:2 [
    0 => array:2 [
      "Paragraph" => "p 1"
      "Number" => "n1"
    ]
    1 => array:2 [
      "Paragraph" => "p 2"
      "Number" => "n2"
    ]
  ]
  2 => array:2 [
    0 => array:2 [
      "Text Field" => "text1"
      "Select" => "Select1"
    ]
    1 => array:2 [
      "Text Field" => "text2"
      "Select" => "select2"
    ]
  ]

我想在第一个循环中获得第一个数组

0 => array:2 [
    0 => array:5 [
      "name" => "user1"
      "description" => "user description"
    ]
  ]
  1 => array:2 [
    0 => array:2 [
      "Paragraph" => "p 1"
      "Number" => "n1"
    ]
  ]
  2 => array:2 [
    0 => array:2 [
      "Text Field" => "text1"
      "Select" => "Select1"
    ]
  ]

第二循环

0 => array:2 [
    1 => array:5 [
      "name" => "user2"
      "description" => "user description 2"
    ]
  ]
  1 => array:2 [
    1 => array:2 [
      "Paragraph" => "p 2"
      "Number" => "n2"
    ]
  ]
  2 => array:2 [
    1 => array:2 [
      "Text Field" => "text2"
      "Select" => "select2"
    ]
  ]

我使用嵌套循环,但是我只能从所有数组中获得第一个数组,如何在每个循环中从3个主数组中获得一个数组,以及是否有多个数组

0 个答案:

没有答案