

- #Php explode adding 0 into first slot of array archive
- #Php explode adding 0 into first slot of array registration
- #Php explode adding 0 into first slot of array code
Using the method above, you can access and display any information in the array from the code above. In our case it will display I want to access the Email of the staff in the first array, we'll do the following: The echo $staff displays the email of the staff that falls into the index of 2. The code above is an example of a multidimensional array because it contains more than one array (an array of arrays) with one single variable of $staff. Remember, an array starts counting from index 0. you can access the information of any staff you wish to by using echo $(variable name). 'Email' => $Staffs // This displays the email of the last staff which is $staffs //This displays the Name of the staff in the first array (index 0) which is Derek Emmanuel
#Php explode adding 0 into first slot of array archive
We can use multidimensional arrays to archive this.
#Php explode adding 0 into first slot of array registration
Suppose we want to store the Names, Registration Numbers, and Emails of some of the staff working in a particular company. In general, multidimensional arrays allow you to store multiple arrays in a single variable. This means that every element in the array holds a sub-array within it. You can think of a multidimensional array as an array of arrays. The values of the array are 17, 18, 16, and 17. The keys of the array are scott_Mcall, Stalenski, Lydia, Allision, and we used them to assign the age to each student. The code above is an example of an associative array. For example: 17,Įcho $student_age //this code will display the age of Scot_Mcall as 17Įcho $student_age //this code will display the age of stalenski as 18Įcho $student_age //this code will display the age of Lydia as 16Įcho $student_age //this code will display the age of Allision as 17 We can use the Associative array method to get it done. Suppose we want to assign ages to a group of high school students with their names.

Let's look at how each one works in more detail. There are different types of arrays in PHP. So whenever you want to call the first value of an array you start with 0 then the next is 1.and so on. To create an array in PHP, we use the array function array( ).īy default, an array of any variable starts with the 0 index. An array is a special variable that we use to store or hold more than one value in a single variable without having to create more variables to store those values.
