SlideShare uma empresa Scribd logo
1 de 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”;
?>

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Semelhante a 2. array and numerical arrays

Semelhante a 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
 

Último

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
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
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Último (20)

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
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
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

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