SlideShare a Scribd company logo
ARRAY
SOURCE: PENSYARAH UITM JASIN, MELAKA
• A variable of the storage area holding a number or text.
• Array will hold only ONE value.
• An array is a special variable, which can store multiple value in one single
variable.
• If you have a list of items (a list of car names, for example), storing the cars
in the single variables look like this :
• An array can hold all your variable value under a single name and you can
easily accessed the value by referring to the array name.
• Each element in the array has its own index so that it can be easily
accessed.
WHAT IS ARRAY?
<?php
$car1 = “Saab”;
$car2 = “Volvo”;
$car3 = “BMW”;
?>
TYPES OF ARRAY
04
01 Numeric Array
An array with a numeric arrays.
02 Associative Array
An array where each ID key is associated with a value.
03 Multidimensional Array
An array containing one or more arrays.
A numeric array stores each array element with a numeric index.
There are 2 methods to create a numeric array.
1. In the following example the index are automatically assigned (the index
starts at 0):
2. In the following example we assigned the index manually:
NUMERIC ARRAYS
<?php
$cars = array(“Saab”, “Volvo, ”BMW”, “Toyota”);
?>
<?php
$cars[0] = “Saab”;
$cars[1] = “Volvo”;
$cars[2] = “BMW”;
$cars[3] = “Toyota”;
?>
In the following example you access the variable values by referring to the
array name and index:
1. The code above will show the output:
NUMERIC ARRAYS
Proton Exora and Inokom are Malaysian cars.
<?php
$cars[0] = “Proton Exora”;
$cars[1] = “Volvo”;
$cars[2] = “Inokom”;
$cars[3] = “Toyota”;
echo $cars[0] . “ and ” . $cars[2] . “ are Malaysian cars”;
?>

More Related Content

PPTX
Types of Arrays
PPTX
Loops and arrays
PPTX
ArrayList in JAVA
PPTX
Array in c
PDF
PHP Basic & Arrays
PPTX
How to Create an Array & types in PHP
PDF
Java basic datatypes
Types of Arrays
Loops and arrays
ArrayList in JAVA
Array in c
PHP Basic & Arrays
How to Create an Array & types in PHP
Java basic datatypes

What's hot (15)

PPTX
Arrays - R.D.Sivakumar
PPTX
PPt. on An _Array in C
PPTX
Chapter 6 java
PDF
Arrays in C++
PPT
Presentation of array
DOCX
Java array
PDF
Android ui adapter
PPTX
Collections Array list
PPTX
Data structures2
PPTX
Java Chapter 05 - Conditions & Loops: part 7
PPTX
Javascript ADT - List
PPTX
Arrays
PPTX
Data structures - unit 1
PPTX
Collections (1)
DOCX
what is arrays in c language
Arrays - R.D.Sivakumar
PPt. on An _Array in C
Chapter 6 java
Arrays in C++
Presentation of array
Java array
Android ui adapter
Collections Array list
Data structures2
Java Chapter 05 - Conditions & Loops: part 7
Javascript ADT - List
Arrays
Data structures - unit 1
Collections (1)
what is arrays in c language
Ad

Similar to 2. array and numerical arrays (20)

PPTX
ARRAYS.pptx
PPTX
Lesson 11 one dimensional array
PPTX
Mod 12
PPTX
Basics of array.pptx
PPTX
Arrays In C Language
DOCX
Array andfunction
ODP
C++ arrays part1
PPT
Arrays
PPTX
Web Application Development using PHP Chapter 4
PPTX
Arrays.pptx
PPT
Lecture 2a arrays
PPTX
arrays.pptx
DOCX
PPTX
Arrays in Reading.pptx
PPTX
C# Array.pptx
PPTX
ADVANCED DATA STRUCTURES AND ALGORITHMS.pptx
PDF
java.pdf
PPSX
javascript arrays
PPTX
Arrays In C++
PPTX
PHP array 1
ARRAYS.pptx
Lesson 11 one dimensional array
Mod 12
Basics of array.pptx
Arrays In C Language
Array andfunction
C++ arrays part1
Arrays
Web Application Development using PHP Chapter 4
Arrays.pptx
Lecture 2a arrays
arrays.pptx
Arrays in Reading.pptx
C# Array.pptx
ADVANCED DATA STRUCTURES AND ALGORITHMS.pptx
java.pdf
javascript arrays
Arrays In C++
PHP array 1
Ad

Recently uploaded (20)

PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
master seminar digital applications in india
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Lesson notes of climatology university.
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Computing-Curriculum for Schools in Ghana
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
master seminar digital applications in india
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Supply Chain Operations Speaking Notes -ICLT Program
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Renaissance Architecture: A Journey from Faith to Humanism
TR - Agricultural Crops Production NC III.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
102 student loan defaulters named and shamed – Is someone you know on the list?
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Lesson notes of climatology university.
GDM (1) (1).pptx small presentation for students
human mycosis Human fungal infections are called human mycosis..pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
RMMM.pdf make it easy to upload and study
VCE English Exam - Section C Student Revision Booklet
Computing-Curriculum for Schools in Ghana
2.FourierTransform-ShortQuestionswithAnswers.pdf
Anesthesia in Laparoscopic Surgery in India
Pharmacology of Heart Failure /Pharmacotherapy of CHF

2. array and numerical arrays

  • 2. • A variable of the storage area holding a number or text. • Array will hold only ONE value. • An array is a special variable, which can store multiple value in one single variable. • If you have a list of items (a list of car names, for example), storing the cars in the single variables look like this : • An array can hold all your variable value under a single name and you can easily accessed the value by referring to the array name. • Each element in the array has its own index so that it can be easily accessed. WHAT IS ARRAY? <?php $car1 = “Saab”; $car2 = “Volvo”; $car3 = “BMW”; ?>
  • 3. TYPES OF ARRAY 04 01 Numeric Array An array with a numeric arrays. 02 Associative Array An array where each ID key is associated with a value. 03 Multidimensional Array An array containing one or more arrays.
  • 4. A numeric array stores each array element with a numeric index. There are 2 methods to create a numeric array. 1. In the following example the index are automatically assigned (the index starts at 0): 2. In the following example we assigned the index manually: NUMERIC ARRAYS <?php $cars = array(“Saab”, “Volvo, ”BMW”, “Toyota”); ?> <?php $cars[0] = “Saab”; $cars[1] = “Volvo”; $cars[2] = “BMW”; $cars[3] = “Toyota”; ?>
  • 5. In the following example you access the variable values by referring to the array name and index: 1. The code above will show the output: NUMERIC ARRAYS Proton Exora and Inokom are Malaysian cars. <?php $cars[0] = “Proton Exora”; $cars[1] = “Volvo”; $cars[2] = “Inokom”; $cars[3] = “Toyota”; echo $cars[0] . “ and ” . $cars[2] . “ are Malaysian cars”; ?>