简体   繁体   中英

php array indexes targeting an index with the same name of another array?

Hi I understand that this might be easy for you but I have just started some basic studying on php.I would like to ask what is the possible way to get the 2nd index of an array for example: Supposing that we have 2 arrays:

  //simple logic
  array(2) [name, gender];
  array(3)[id, name, age];

Is there any possible way to target the index 'name' but only from the second array ?

Simple example on how to separate arrays.

<?php
$array1['name'] = "John";
$array1['age'] = "24";

$array2['name'] = "Mike";
$array2['age'] = "26";

/* At this point the array structure is as follows
array1 ('name'=>'John',
        'age'=>'24')

array2 ('name'=>'Mike',
        'age'=>'26')
*/

echo $array1['name']; // prints out John

echo $array2['name']; // prints out Mike
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM