SlideShare a Scribd company logo
Lecturer:
M.Zalmai “Rahmani”
rahmani.zalmai@gmail.com
Web Programming II
Lecture 03
PHP Basic & Arrays
Azma Institute
Database Department
PHP Arrays
What is an Array?
 A variable is a storage area holding a number or text.The problem is, a
variable will hold only one value.
 An array is a special variable, which can store multiple values in one single
variable.
 If you have a list of items (a list of car names, for example), storing the
cars in single variables could look like this:
$cars1="Saab";
$cars2="Volvo";
$cars3="BMW";
 However, what if you want to loop through the cars and find a specific
one? And what if you had not 3 cars, but 300?
The best solution here is to use an array!
PHP Arrays
What is an Array?
 An array can hold all your variable values under a single name. And you
can access the values by referring to the array name.
 Each element in the array has its own index so that it can be easily
accessed.
 In PHP, there are three kind of arrays:
• Numeric array - An array with a numeric index
• Associative array - An array where each ID key is associated with a value
• Multidimensional array - An array containing one or more arrays
PHP Arrays
Numeric Arrays
 A numeric array stores each array element with a numeric index.
There are two methods to create a numeric array.
PHP Arrays
Example
PHP Arrays
Associative Arrays
 An associative array, each ID key is associated with a value.
 When storing data about specific named values, a numerical array is not
always the best way to do it.
 With associative arrays we can use the values as keys and assign values to
them.
PHP Arrays
Example
PHP Arrays
Example
PHP Arrays
Multidimensional Arrays is Not Recommend in this Course
We will study in next semester
PHP Arrays
Multidimensional Arrays
 In a multidimensional array, each element in the main array can also be an
array. And each element in the sub-array can be an array, and so on.
PHP Arrays
www.w3schools.com
PHP Basic & Arrays

More Related Content

What's hot (20)

PPTX
Types of Arrays
Ans Ali
 
PPTX
2. array and numerical arrays
NurAliaAqilaMuhalis
 
PPTX
Array in Java
Ali shah
 
PDF
Arrays in PHP
Vineet Kumar Saini
 
PPTX
Working with arrays in php
Kamal Acharya
 
PPT
Php array
Core Lee
 
PDF
SPL 10 | One Dimensional Array in C
Mohammad Imam Hossain
 
PPTX
Array
hinanshu
 
PDF
PHP Unit 4 arrays
Kumar
 
PDF
Php array
Nikul Shah
 
PPTX
PPt. on An _Array in C
RohitAgrawal119182
 
PPT
Array1
Rajendran
 
PPTX
Php arrays
1crazyguy
 
PPT
Data structures
Rokonuzzaman Rony
 
PPTX
Array in c
Harsh Bhanushali
 
PDF
Arrays Java
Jose Sumba
 
PPT
Arrays in PHP
Compare Infobase Limited
 
PPTX
12. arrays
M H Buddhika Ariyaratne
 
PPT
PHP array 2
Mudasir Syed
 
Types of Arrays
Ans Ali
 
2. array and numerical arrays
NurAliaAqilaMuhalis
 
Array in Java
Ali shah
 
Arrays in PHP
Vineet Kumar Saini
 
Working with arrays in php
Kamal Acharya
 
Php array
Core Lee
 
SPL 10 | One Dimensional Array in C
Mohammad Imam Hossain
 
Array
hinanshu
 
PHP Unit 4 arrays
Kumar
 
Php array
Nikul Shah
 
PPt. on An _Array in C
RohitAgrawal119182
 
Array1
Rajendran
 
Php arrays
1crazyguy
 
Data structures
Rokonuzzaman Rony
 
Array in c
Harsh Bhanushali
 
Arrays Java
Jose Sumba
 
PHP array 2
Mudasir Syed
 

Similar to PHP Basic & Arrays (20)

PPT
Web Technology - PHP Arrays
Tarang Desai
 
PPTX
Arrays in php
soumyaharitha
 
PPTX
Web Application Development using PHP Chapter 4
Mohd Harris Ahmad Jaal
 
PPT
PHP - Introduction to PHP Arrays
Vibrant Technologies & Computers
 
DOCX
Array andfunction
Girmachew Tilahun
 
PPT
PHP-04-Arrays.ppt
Leandro660423
 
PPTX
Unit 2-Arrays.pptx
mythili213835
 
PDF
Array String - Web Programming
Amirul Azhar
 
PPTX
PHP Arrays_Introduction
To Sum It Up
 
PDF
PHP-Part3
Ahmed Saihood
 
PPT
Chapter 04 array
Dhani Ahmad
 
PPTX
Lecture 5 array in PHP.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
ZahouAmel1
 
PPTX
Chapter 2 wbp.pptx
40NehaPagariya
 
PDF
Hsc IT 5. Server-Side Scripting (PHP).pdf
AAFREEN SHAIKH
 
PDF
8 covid19 - chp 07 - php array (shared)
YUSRA FERNANDO
 
PPTX
5 Arry in PHP.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
ayushmishraaa09
 
PPTX
Arrays in PHP
davidahaskins
 
PDF
Lecture2_IntroductionToPHP_Spring2023.pdf
ShaimaaMohamedGalal
 
PPTX
Introduction to PHP_ Lexical structure_Array_Function_String
DeepakUlape2
 
Web Technology - PHP Arrays
Tarang Desai
 
Arrays in php
soumyaharitha
 
Web Application Development using PHP Chapter 4
Mohd Harris Ahmad Jaal
 
PHP - Introduction to PHP Arrays
Vibrant Technologies & Computers
 
Array andfunction
Girmachew Tilahun
 
PHP-04-Arrays.ppt
Leandro660423
 
Unit 2-Arrays.pptx
mythili213835
 
Array String - Web Programming
Amirul Azhar
 
PHP Arrays_Introduction
To Sum It Up
 
PHP-Part3
Ahmed Saihood
 
Chapter 04 array
Dhani Ahmad
 
Lecture 5 array in PHP.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
ZahouAmel1
 
Chapter 2 wbp.pptx
40NehaPagariya
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
AAFREEN SHAIKH
 
8 covid19 - chp 07 - php array (shared)
YUSRA FERNANDO
 
5 Arry in PHP.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
ayushmishraaa09
 
Arrays in PHP
davidahaskins
 
Lecture2_IntroductionToPHP_Spring2023.pdf
ShaimaaMohamedGalal
 
Introduction to PHP_ Lexical structure_Array_Function_String
DeepakUlape2
 
Ad

Recently uploaded (20)

PPTX
EO4EU Ocean Monitoring: Maritime Weather Routing Optimsation Use Case
EO4EU
 
PDF
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
 
PDF
Designing Accessible Content Blocks (1).pdf
jaclynmennie1
 
PDF
>Wondershare Filmora Crack Free Download 2025
utfefguu
 
PDF
AWS Consulting Services: Empowering Digital Transformation with Nlineaxis
Nlineaxis IT Solutions Pvt Ltd
 
PDF
>Nitro Pro Crack 14.36.1.0 + Keygen Free Download [Latest]
utfefguu
 
PDF
Continouous failure - Why do we make our lives hard?
Papp Krisztián
 
PPTX
Iobit Driver Booster Pro 12 Crack Free Download
chaudhryakashoo065
 
PPTX
Quality on Autopilot: Scaling Testing in Uyuni
Oscar Barrios Torrero
 
PDF
Laboratory Workflows Digitalized and live in 90 days with Scifeon´s SAPPA P...
info969686
 
PPTX
How Can Recruitment Management Software Improve Hiring Efficiency?
HireME
 
PDF
Dealing with JSON in the relational world
Andres Almiray
 
PDF
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
 
PDF
IObit Uninstaller Pro 14.3.1.8 Crack for Windows Latest
utfefguu
 
PPTX
computer forensics encase emager app exp6 1.pptx
ssuser343e92
 
PDF
Rewards and Recognition (2).pdf
ethan Talor
 
PPTX
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
Nabin Dhakal
 
PPTX
Automatic_Iperf_Log_Result_Excel_visual_v2.pptx
Chen-Chih Lee
 
PPTX
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
 
PPTX
CONCEPT OF PROGRAMMING in language .pptx
tamim41
 
EO4EU Ocean Monitoring: Maritime Weather Routing Optimsation Use Case
EO4EU
 
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
 
Designing Accessible Content Blocks (1).pdf
jaclynmennie1
 
>Wondershare Filmora Crack Free Download 2025
utfefguu
 
AWS Consulting Services: Empowering Digital Transformation with Nlineaxis
Nlineaxis IT Solutions Pvt Ltd
 
>Nitro Pro Crack 14.36.1.0 + Keygen Free Download [Latest]
utfefguu
 
Continouous failure - Why do we make our lives hard?
Papp Krisztián
 
Iobit Driver Booster Pro 12 Crack Free Download
chaudhryakashoo065
 
Quality on Autopilot: Scaling Testing in Uyuni
Oscar Barrios Torrero
 
Laboratory Workflows Digitalized and live in 90 days with Scifeon´s SAPPA P...
info969686
 
How Can Recruitment Management Software Improve Hiring Efficiency?
HireME
 
Dealing with JSON in the relational world
Andres Almiray
 
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
 
IObit Uninstaller Pro 14.3.1.8 Crack for Windows Latest
utfefguu
 
computer forensics encase emager app exp6 1.pptx
ssuser343e92
 
Rewards and Recognition (2).pdf
ethan Talor
 
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
Nabin Dhakal
 
Automatic_Iperf_Log_Result_Excel_visual_v2.pptx
Chen-Chih Lee
 
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
 
CONCEPT OF PROGRAMMING in language .pptx
tamim41
 
Ad

PHP Basic & Arrays

  • 1. Lecturer: M.Zalmai “Rahmani” [email protected] Web Programming II Lecture 03 PHP Basic & Arrays Azma Institute Database Department
  • 2. PHP Arrays What is an Array?  A variable is a storage area holding a number or text.The problem is, a variable will hold only one value.  An array is a special variable, which can store multiple values in one single variable.  If you have a list of items (a list of car names, for example), storing the cars in single variables could look like this: $cars1="Saab"; $cars2="Volvo"; $cars3="BMW";  However, what if you want to loop through the cars and find a specific one? And what if you had not 3 cars, but 300? The best solution here is to use an array!
  • 3. PHP Arrays What is an Array?  An array can hold all your variable values under a single name. And you can access the values by referring to the array name.  Each element in the array has its own index so that it can be easily accessed.  In PHP, there are three kind of arrays: • Numeric array - An array with a numeric index • Associative array - An array where each ID key is associated with a value • Multidimensional array - An array containing one or more arrays
  • 4. PHP Arrays Numeric Arrays  A numeric array stores each array element with a numeric index. There are two methods to create a numeric array.
  • 6. PHP Arrays Associative Arrays  An associative array, each ID key is associated with a value.  When storing data about specific named values, a numerical array is not always the best way to do it.  With associative arrays we can use the values as keys and assign values to them.
  • 9. PHP Arrays Multidimensional Arrays is Not Recommend in this Course We will study in next semester
  • 10. PHP Arrays Multidimensional Arrays  In a multidimensional array, each element in the main array can also be an array. And each element in the sub-array can be an array, and so on.