1

I have stored many arrays in a single associative array and assigned key values simple number counting.

How can I extract one of those array from the associative array?

my array:

$arr = array(
        1 => array("ask","bat","cod","dig","egg","fur","gap","hay","ice","jar","kin","lee"), 
        2 => array("add","big","cap","day","eye","fat","gel","hop","ink","jog","key","law"),   
        3 => array("axe","bin","cel","don","eat","fig","gig","hut","ion","jin","kid","lip")
    );

I want to store the array indexed say 2 in $arr_chosen, what will be the syntax to do so?

1
  • 1
    $arr_chosen=$arr[2]; Commented May 3, 2015 at 21:35

2 Answers 2

1
$arr = array(
        1 => array("ask","bat","cod","dig","egg","fur","gap","hay","ice","jar","kin","lee"), 
        2 => array("add","big","cap","day","eye","fat","gel","hop","ink","jog","key","law"),   
        3 => array("axe","bin","cel","don","eat","fig","gig","hut","ion","jin","kid","lip")
    );
$arr_chosen = $arr[2];
Sign up to request clarification or add additional context in comments.

Comments

1

You can extract an array by doing

$arr_chosen = $arr[2]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.