Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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 ?

share|improve this question
    
Do you mean to print name from second array? –  Fabio Mar 7 at 1:15
    
$array['name'] –  ElefantPhace Mar 7 at 1:16
add comment

1 Answer

up vote 1 down vote accepted

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
?>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.