Hello, welcome to zhullyblog. If this is your first time here , please
Subscribe to Zhullyblog by Email to get latest tutorial.
PHP Arrays: Index , Associative , Multidimensional Arrays- Zhullyblog
What is an array?
An array is a data structure that stores one or more value under a single variable. This means that you can store several data in a single variable.
Let's take for instance storing cars names.
statement.
<?php
$car1= " Rolls royce";
$car2= "Toyota";
$car3= "Benz";
$car4= "Jeep";
?>
Types of Arrays
There are three types of Arrays in PHP. They are :
- • Indexed array / Numeric array
- • Associative array
- • Multidimensional array
•
Index Array
An index array stores each element present in it with a numerical index. The index starts with 0. Here is an example.
statement.
<?php
$car1 [0]= " Rolls royce";
$car2 [1]= "Toyota";
$car3 [2]= "Benz";
$car4 [3]= "Jeep";
?>
Associative Array
An Associative array is an array that has its value to be assigned to arbitrary and user defined string.
Here is an example.
statement.
<?php
$car1 ["Bisi"]= " Rolls royce";
$car2 ["John"]= "Toyota";
$car3 ["Linda"]= "Benz";
$car4 ["Josh"]= "Jeep";
?>
Multidimensional Arrays
A Multidimensional array is an array in which each element can be an array and will contain other element in it's subarray.
statement.
<?php
$about = array(
array(
"name" => "Emily";
"age" => "10";),
array (
"name" => "Divine";
"age" => "12";)
);
?>
Please share
Follow us on
1) Introduction to PHP
2) PHP Syntax
3) PHP Comment
4) PHP Data types
5) PHP Variables
6) PHP Echo and Print - How to display output
7) PHP If, if else and if elseif statement
8) PHP Lopps - While , Do while
9) PHP Strings : How to create and manipulate Strings
11)PHP FORMS: How to create a form, access data submitted in the form by user
OTHER TUTORIALS
Comments
Post a Comment