SlideShare a Scribd company logo
PHP Arrays
ELEGANT AND EASY WAYS TO WORK WITH THEM. PART1
I wonder what arrays are all about!
Well, to begin with they are used to store data.
Just like you store data in variables E.g. $x=5;
The major difference between arrays and variables being:
Variables aren’t as flexible as arrays.
Arrays can be used to store Homogeneous(All Ints or Floats) or
Heterogeneous(Int, Float, Char) data.
Tell me more
There are 3 types of arrays in PHP
Indexed: Accessed via a particular Index.
E.g. $x[0];
Associative: Accessed via a particular key.
E.g. $x[‘name’];
Multidimensional: Contain more than one arrays of same or different types.
E.g. $x[0][1];
Indexed arrays
How do I declare and initialize them?
$country = array(“India”, “Canada”, “USA”);
That’s how you do it. Don’t use the other way. It’s time consuming!
Indexed arrays
I want some action! Show me how to view contents of the array we just
created.
Okay, here you go – This is how you access the elements.
Echo $country[1]; #Will show you Canada.
Why?
Arrays start with a ‘0’ as primary Index.
Indexed arrays - Show me more!
That was kids stuff. Show me how to print all the elements.
Hmm, you want more action huh?
Here you go –
For($anyvariable=0; $anyvariable<count($country); $anyvariable++){
Echo $country[$anyvariable];
}
Note: count function will contain the length of the array. In this case 3.
Indexed arrays - Pay back time!
Are you kidding me? “Practice makes a man perfect”
You show me more; assignment time!
a. Create an array with numbers 1 to 20 inside it.
b. Show me how you’d print every odd number between 3 and 20.
c. If that was fun, when you arrive at the 17 make it yell out “Seventeen”.
Did you make it till here already? Very good. I appreciate your time and
efforts.
End of Part1
 End of Part1.
 This document will contain links to all other documents when complete.
 Estimated completion time: December 5th 2015 or sooner.

More Related Content

PPTX
How to Create an Array & types in PHP
Ajit Sinha
 
PPTX
Array in php
ilakkiya
 
PPT
Intro to Lists
primeteacher32
 
PDF
Python for Everybody - Solution Challenge 2021
AshwinRaj57
 
PDF
Chapter 5a -_array_-in_class-
Khairunnisa Abdullah
 
PDF
Python standard data types
Learnbay Datascience
 
PPT
Introduction to perl_control structures
Vamshi Santhapuri
 
PPTX
Python l3
Aishwarya Deshmukh
 
How to Create an Array & types in PHP
Ajit Sinha
 
Array in php
ilakkiya
 
Intro to Lists
primeteacher32
 
Python for Everybody - Solution Challenge 2021
AshwinRaj57
 
Chapter 5a -_array_-in_class-
Khairunnisa Abdullah
 
Python standard data types
Learnbay Datascience
 
Introduction to perl_control structures
Vamshi Santhapuri
 

Viewers also liked (17)

PPTX
Milho transgênico
Aline Karolayne
 
ODP
Palazzi
Julien Sorel
 
PDF
Nuevo stemo2
CARLOS FELIX
 
PDF
Diploma Certificate
Umair Khan
 
PDF
SYNERGY4
Carlos Felix
 
PPTX
Дерматологический кабинет
Scientific Research Institute of Children's Infections, Saint-Petersburg, Russia
 
DOCX
Cautions
marioacostam
 
PDF
Nuevo synergyo2
CARLOS FELIX
 
PPTX
A Day in the Life of Digital Professional
Michael Yung
 
PDF
2016 Frente 3 módulo 9b transporte seiva bruta
Colégio Batista de Mantena
 
PDF
Automação de Testes de Regressão - Selenium
Maiele Ranzan
 
PDF
PROMOCIONES SYNERGYO2
SYNERGYO2 GLOBAL
 
PDF
EL VALOR RESIDUAL
Carlos Felix
 
PPTX
RF Power Amplifier Tutorial (2) Class A, B and C
Seong-Hun Choe
 
PDF
Testes de segurança desafios e oportunidades
Qualister
 
PPT
2016 Frente 1 módulo 12 Herança dos genes cromossomos sexuais
Colégio Batista de Mantena
 
PDF
Nokia Strategy Presentation
Murali Erraguntala
 
Milho transgênico
Aline Karolayne
 
Palazzi
Julien Sorel
 
Nuevo stemo2
CARLOS FELIX
 
Diploma Certificate
Umair Khan
 
SYNERGY4
Carlos Felix
 
Cautions
marioacostam
 
Nuevo synergyo2
CARLOS FELIX
 
A Day in the Life of Digital Professional
Michael Yung
 
2016 Frente 3 módulo 9b transporte seiva bruta
Colégio Batista de Mantena
 
Automação de Testes de Regressão - Selenium
Maiele Ranzan
 
PROMOCIONES SYNERGYO2
SYNERGYO2 GLOBAL
 
EL VALOR RESIDUAL
Carlos Felix
 
RF Power Amplifier Tutorial (2) Class A, B and C
Seong-Hun Choe
 
Testes de segurança desafios e oportunidades
Qualister
 
2016 Frente 1 módulo 12 Herança dos genes cromossomos sexuais
Colégio Batista de Mantena
 
Nokia Strategy Presentation
Murali Erraguntala
 
Ad

Similar to Php arrays (20)

PPTX
PHP array 1
Mudasir Syed
 
PPT
Web Technology - PHP Arrays
Tarang Desai
 
PPTX
Unit 2-Arrays.pptx
mythili213835
 
PPT
PHP array 2
Mudasir Syed
 
PPTX
Lecture 5 array in PHP.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
ZahouAmel1
 
PPT
PHP - Introduction to PHP Arrays
Vibrant Technologies & Computers
 
PDF
4.1 PHP Arrays
Jalpesh Vasa
 
PDF
PHP Basic & Arrays
M.Zalmai Rahmani
 
PPTX
Arrays in php
soumyaharitha
 
PPTX
Chapter 2 wbp.pptx
40NehaPagariya
 
PPTX
Chap 3php array part1
monikadeshmane
 
PPTX
5 Arry in PHP.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
ayushmishraaa09
 
PPTX
PHP Arrays_Introduction
To Sum It Up
 
PDF
Array String - Web Programming
Amirul Azhar
 
PPTX
Arrays in PHP
davidahaskins
 
DOCX
Array andfunction
Girmachew Tilahun
 
PPTX
Array
hinanshu
 
PPTX
Web Application Development using PHP Chapter 4
Mohd Harris Ahmad Jaal
 
PPT
Php my sql - functions - arrays - tutorial - programmerblog.net
Programmer Blog
 
PPT
PHP-04-Arrays.ppt
Leandro660423
 
PHP array 1
Mudasir Syed
 
Web Technology - PHP Arrays
Tarang Desai
 
Unit 2-Arrays.pptx
mythili213835
 
PHP array 2
Mudasir Syed
 
Lecture 5 array in PHP.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
ZahouAmel1
 
PHP - Introduction to PHP Arrays
Vibrant Technologies & Computers
 
4.1 PHP Arrays
Jalpesh Vasa
 
PHP Basic & Arrays
M.Zalmai Rahmani
 
Arrays in php
soumyaharitha
 
Chapter 2 wbp.pptx
40NehaPagariya
 
Chap 3php array part1
monikadeshmane
 
5 Arry in PHP.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
ayushmishraaa09
 
PHP Arrays_Introduction
To Sum It Up
 
Array String - Web Programming
Amirul Azhar
 
Arrays in PHP
davidahaskins
 
Array andfunction
Girmachew Tilahun
 
Array
hinanshu
 
Web Application Development using PHP Chapter 4
Mohd Harris Ahmad Jaal
 
Php my sql - functions - arrays - tutorial - programmerblog.net
Programmer Blog
 
PHP-04-Arrays.ppt
Leandro660423
 
Ad

Recently uploaded (20)

PDF
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
CIFDAQ
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PDF
agentic-ai-and-the-future-of-autonomous-systems.pdf
siddharthnetsavvies
 
PDF
GYTPOL If You Give a Hacker a Host
linda296484
 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
PPTX
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
 
PPTX
C Programming Basics concept krnppt.pptx
Karan Prajapat
 
PDF
Software Development Company | KodekX
KodekX
 
PDF
Software Development Methodologies in 2025
KodekX
 
PPTX
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
Captain IT
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
This slide provides an overview Technology
mineshkharadi333
 
PDF
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
CIFDAQ
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
agentic-ai-and-the-future-of-autonomous-systems.pdf
siddharthnetsavvies
 
GYTPOL If You Give a Hacker a Host
linda296484
 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
 
C Programming Basics concept krnppt.pptx
Karan Prajapat
 
Software Development Company | KodekX
KodekX
 
Software Development Methodologies in 2025
KodekX
 
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
Captain IT
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
Doc9.....................................
SofiaCollazos
 
This slide provides an overview Technology
mineshkharadi333
 
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 

Php arrays

  • 1. PHP Arrays ELEGANT AND EASY WAYS TO WORK WITH THEM. PART1
  • 2. I wonder what arrays are all about! Well, to begin with they are used to store data. Just like you store data in variables E.g. $x=5; The major difference between arrays and variables being: Variables aren’t as flexible as arrays. Arrays can be used to store Homogeneous(All Ints or Floats) or Heterogeneous(Int, Float, Char) data.
  • 3. Tell me more There are 3 types of arrays in PHP Indexed: Accessed via a particular Index. E.g. $x[0]; Associative: Accessed via a particular key. E.g. $x[‘name’]; Multidimensional: Contain more than one arrays of same or different types. E.g. $x[0][1];
  • 4. Indexed arrays How do I declare and initialize them? $country = array(“India”, “Canada”, “USA”); That’s how you do it. Don’t use the other way. It’s time consuming!
  • 5. Indexed arrays I want some action! Show me how to view contents of the array we just created. Okay, here you go – This is how you access the elements. Echo $country[1]; #Will show you Canada. Why? Arrays start with a ‘0’ as primary Index.
  • 6. Indexed arrays - Show me more! That was kids stuff. Show me how to print all the elements. Hmm, you want more action huh? Here you go – For($anyvariable=0; $anyvariable<count($country); $anyvariable++){ Echo $country[$anyvariable]; } Note: count function will contain the length of the array. In this case 3.
  • 7. Indexed arrays - Pay back time! Are you kidding me? “Practice makes a man perfect” You show me more; assignment time! a. Create an array with numbers 1 to 20 inside it. b. Show me how you’d print every odd number between 3 and 20. c. If that was fun, when you arrive at the 17 make it yell out “Seventeen”. Did you make it till here already? Very good. I appreciate your time and efforts.
  • 8. End of Part1  End of Part1.  This document will contain links to all other documents when complete.  Estimated completion time: December 5th 2015 or sooner.