in Education by
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 7 years ago. Improve this question 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. Select the correct answer from above options JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
 
Best answer
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]; }

Related questions

0 votes
    I store all of the Google Maps marker objects in a single array. Right now I am trying to set up ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    How do you think I can get the intersection of the below-given array? a=np.array([[[[0,0],[0,1]],[[1,1],[1,1]]] ... , [[0, 1], [1, 1]]] Select the correct answer from above options...
asked Jan 9, 2022 in Education by JackTerrance
0 votes
    In multidimensional array mySubject, which of the following will allow assigning the value 100 in position 5 of the third mySubject array? 1 ... ][4] = 100 5. mySubject[3][5] = 100...
asked Feb 24, 2021 in Technology by JackTerrance
+1 vote
    In multidimensional array mySubject, which of the following will allow assigning the value 100 in position 5 of the third mySubject array? a ... 2][4] = 100 e)mySubject[3][5] = 100...
asked Oct 8, 2020 in Technology by JackTerrance
0 votes
    I currently have 2 classes: workerListClass workerClass The workerListClass gets a list of work with ids from ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    How to solve array problem? $kuponlar = $core->query("SELECT * FROM kupon WHERE kupon_durum = ?", ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    How to solve array problem? $kuponlar = $core->query("SELECT * FROM kupon WHERE kupon_durum = ?", ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 13, 2022 in Education by JackTerrance
0 votes
    I try to print images with a for loop but the images dont load. The images are in the same ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    I try to print images with a for loop but the images dont load. The images are in the same ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 10, 2022 in Education by JackTerrance
0 votes
    I am trying to echo out an array using for each but it's not displaying any values. The only ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I am trying to echo out an array using for each but it's not displaying any values. The only ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 25, 2022 in Education by JackTerrance
0 votes
    I am trying to create a simple node.js app on heroku. Here is app.js: console.log("Starting App" ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    new to play and just trying to follow the video on: http://www.playframework.org/ I'm coming so ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    After reading up on some options (sqlite, derby etc...), I've decided to throw down with HSQLDB. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    SA=1000.00 AI=0.12 MP=100.00 def remainb(x): if x==0: return 0 else: return x=(SA+(AI/12)*SA)-MP for ... . run the loop until SA==0). Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
...