简体   繁体   English

仅获取组合在一个数组中的两个数组中的第一个

[英]Get only first of two arrays which are combined in one array

If i var_dump my array $array_name i get the following: 如果我var_dump我的数组$array_name我得到以下内容:

array(4) {
  ["lounge"]=>
  string(0) ""
  ["terrasse"]=>
  string(12) "ab 18:00 Uhr"
 ["vorverkauf"]=>
  string(12) "ab 18:30 Uhr"
  ["titles"]=>
  array(3) {
    ["lounge"]=>
    string(6) "Lounge"
    ["terrasse"]=>
    string(14) "Außenbar"
    ["vorverkauf"]=>
    string(18) "Vorverkauf im 1.UG"
  }
}
array(4) {
  ["lounge"]=>
  string(0) ""
  ["terrasse"]=>
  string(12) "ab 18:00 Uhr"
  ["vorverkauf"]=>
  string(12) "ab 18:30 Uhr"
  ["titles"]=>
  array(3) {
    ["lounge"]=>
    string(6) "Lounge"
    ["terrasse"]=>
    string(14) "Außenbar"
    ["vorverkauf"]=>
    string(18) "Vorverkauf im 1.UG"
  }
}

As you can see these are two arrays BUT they are not within one "master" array. 如您所见,这是两个数组,但它们不在一个“主”数组中。 I'd like to have only the first of these to arrays. 我只想将其中的第一个放入数组。

So i tried 所以我尝试了

var_dump($array_name[0]) which returns NULL var_dump($array_name[0])返回NULL

What am i missing? 我想念什么?

At the end I would like to get ONLY from the first array the following value: 最后,我只想从第一个数组中获得以下值:

Something like $array[0]['titles]['lounge'] should output Lounge $array[0]['titles]['lounge']应该输出Lounge

Loop through each one printing the value And this is because you don't define a key for arrays with in array name 循环遍历每一个打印值,这是因为您没有为数组名称为in的数组定义键

foreach( $array_name as $sub_array_name){
 echo $sub_array_name["titles"]["lounge"];

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过仅接管与第一个具有相同键的第二个数组中的值来合并两个 arrays? - How to merge two arrays by taking over only values from the second array that has the same keys as the first one? 如何比较两个数组的差异并输出仅在一个数组中存在的键? - How can I compare the differences of two arrays and output the key, which only exits in one array? 将两个数组合并到一个表中。 第一列垂直,第二列水平 - Two arrays into one table. First array vertical, second horizontal 合并两个数组,用第二个数组覆盖第一个数组 - Merging two arrays, overwriting first array with second one PHP 将两个数组合并到一个表中。 第一个阵列垂直和水平 - PHP Two Arrays Into One Table. First Array Vertical & Horizontal 合并两个数组,并保留数组名称作为新合并的数组中的键 - Combine two arrays and keep the array name as the key in the newly combined array 两个PHP数组,未设置的位置仅存在于一个数组中 - Two PHP arrays, unset positions that are only present in one array 在键/值上组合两个数组,并用PHP输出组合数组 - Combine two arrays on key/value and output combined array with PHP 从其他数组制作一个递归组合数组 - Make one recursive combined array from other arrays 一个数组中的两个数组PHP - Two arrays in one array PHP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM