Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8138527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:31:02+00:00 2026-06-06T11:31:02+00:00

I have the following array. It contains nicknames and names: $nickAndNames = array( array(

  • 0

I have the following array. It contains nicknames and names:

$nickAndNames = array( 
    array( "Johnie", "John Larson" ),
    array ("Maggie", "Margaret London" ),
    array("Nic","Nicholas Carradine")
);

Can you please help me to print just the first elements? I mean Johnie, Maggie, Nic.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:31:03+00:00Added an answer on June 6, 2026 at 11:31 am

    Each element of the array is another array. Each element of this inner array in turn contains 2 elements: element 0 (a string, the nickname) and element 1 (another string, the name). Therefore, you’d first need to loop through the $nicksAndNames array, and then display the inner array’s first element (which is element 0):

    // loop through $nickAndNames and assign, in turn, each inner array
    // to a variable named $nickAndName
    foreach ($nickAndNames as $nickAndName) {
        // this $nickAndName variable now contains the inner array, something like:
        // array("Johnie", "John Larson"), so "Johnie" is the first element,
        // element 0
        echo $nickAndName[0];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have an array numbers that contains the following values: int numbers
I have a session that contains an array. The array contains the following data:
I have the following php loop that takes an array that contains a set
I have the following view model which contains an array of elements function ReservationsViewModel()
I have following array that contains information on each file.but it is in single
I have the following array that contains lots of \/, since the array is
I have an array which contains following values: str[0]= MeterNr 29202 str[1]=- 20111101: position
I have the following problem: I have this multi-level array (nested array) which contains
Probaly a simple one for you but I have the following array that contains
I have the following issue: A java object contains two arrays of core datastore

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.