SlideShare ist ein Scribd-Unternehmen logo
1 von 5
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”;
?>

Weitere ähnliche Inhalte

Was ist angesagt?

Android ui adapter
Android ui adapterAndroid ui adapter
Android ui adapterKrazy Koder
 
Collections Array list
Collections Array listCollections Array list
Collections Array listRatnaJava
 
Java Chapter 05 - Conditions & Loops: part 7
Java Chapter 05 - Conditions & Loops: part 7Java Chapter 05 - Conditions & Loops: part 7
Java Chapter 05 - Conditions & Loops: part 7DanWooster1
 
Javascript ADT - List
Javascript   ADT - ListJavascript   ADT - List
Javascript ADT - ListSamuel Santos
 
Data structures - unit 1
Data structures - unit 1Data structures - unit 1
Data structures - unit 1SaranyaP45
 
what is arrays in c language
what is arrays in c languagewhat is arrays in c language
what is arrays in c languageShahbaz Khan
 

Was ist angesagt? (15)

Arrays - R.D.Sivakumar
Arrays - R.D.SivakumarArrays - R.D.Sivakumar
Arrays - R.D.Sivakumar
 
PPt. on An _Array in C
PPt. on An _Array in CPPt. on An _Array in C
PPt. on An _Array in C
 
Chapter 6 java
Chapter 6 javaChapter 6 java
Chapter 6 java
 
Arrays in C++
Arrays in C++Arrays in C++
Arrays in C++
 
Presentation of array
Presentation of arrayPresentation of array
Presentation of array
 
Java array
Java arrayJava array
Java array
 
Android ui adapter
Android ui adapterAndroid ui adapter
Android ui adapter
 
Collections Array list
Collections Array listCollections Array list
Collections Array list
 
Data structures2
Data structures2Data structures2
Data structures2
 
Java Chapter 05 - Conditions & Loops: part 7
Java Chapter 05 - Conditions & Loops: part 7Java Chapter 05 - Conditions & Loops: part 7
Java Chapter 05 - Conditions & Loops: part 7
 
Javascript ADT - List
Javascript   ADT - ListJavascript   ADT - List
Javascript ADT - List
 
Arrays
ArraysArrays
Arrays
 
Data structures - unit 1
Data structures - unit 1Data structures - unit 1
Data structures - unit 1
 
Collections (1)
Collections (1)Collections (1)
Collections (1)
 
what is arrays in c language
what is arrays in c languagewhat is arrays in c language
what is arrays in c language
 

Ähnlich wie 2. array and numerical arrays

Ähnlich wie 2. array and numerical arrays (20)

ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
 
Lesson 11 one dimensional array
Lesson 11 one dimensional arrayLesson 11 one dimensional array
Lesson 11 one dimensional array
 
Mod 12
Mod 12Mod 12
Mod 12
 
Basics of array.pptx
Basics of array.pptxBasics of array.pptx
Basics of array.pptx
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
 
Array andfunction
Array andfunctionArray andfunction
Array andfunction
 
C++ arrays part1
C++ arrays part1C++ arrays part1
C++ arrays part1
 
Arrays
ArraysArrays
Arrays
 
Web Application Development using PHP Chapter 4
Web Application Development using PHP Chapter 4Web Application Development using PHP Chapter 4
Web Application Development using PHP Chapter 4
 
Arrays.pptx
Arrays.pptxArrays.pptx
Arrays.pptx
 
Lecture 2a arrays
Lecture 2a arraysLecture 2a arrays
Lecture 2a arrays
 
arrays.pptx
arrays.pptxarrays.pptx
arrays.pptx
 
arrays.docx
arrays.docxarrays.docx
arrays.docx
 
Arrays in Reading.pptx
Arrays in Reading.pptxArrays in Reading.pptx
Arrays in Reading.pptx
 
C# Array.pptx
C# Array.pptxC# Array.pptx
C# Array.pptx
 
java.pdf
java.pdfjava.pdf
java.pdf
 
javascript arrays
javascript arraysjavascript arrays
javascript arrays
 
Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
 
PHP array 1
PHP array 1PHP array 1
PHP array 1
 
Java Arrays
Java ArraysJava Arrays
Java Arrays
 

Kürzlich hochgeladen

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxAmita Gupta
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 

Kürzlich hochgeladen (20)

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 

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”; ?>