SlideShare a Scribd company logo
By Nikul Shah
Nikul Shah 1
Nikul Shah 2
 An array is assigned to a single variable, but it
can hold dozens of individual pieces of
information.
 Each individual bit of information, or row, is
referred to as an array element.
 Within every array element there are two parts:
the value, which contains the actual
information you want to store, and a unique
key which identifies the value.
 you will learn later how key palys an
importanat role in the process of accessing
and manipulating array elements.
Nikul Shah 3
 Keys can either be non-negative integers or
strings.
 Array with integers as key are the most
common type and known as SCALAR ARRAYs.
 Those with key as string are known as
ASSOCIATIVE ARRAY.
Nikul Shah 4
 There are 2 kinds of arrays in php: indexed
and associative arrray.
 Key of indexed array is integer starts with 0.
 Indexed array are used when we identify
things with their position.
 Associative arrays have strings as keys and
behave more like two-columns table.
 The first column is key and second is use to
access value.
Nikul Shah 5
 Numeric array
 Associative Array
 Multidimensional Array.
Nikul Shah 6
 In numeric array have to create only
elements, id will be automatically assigned to
the elements.
example
<?php
$a = array("train", "car","bus");
print_r($a);
?>
output
 Array ( [0] => train [1] => car [2] => bus )
Nikul Shah 7
 In associative array we have create element
with id.
 example
 <?php
 $a =
array("6"=>"train","7"=>"car","8"=>"bus");
 print_r($a);
 ?>
 Out put.
 Array ( [6] => train [7] => car [8] => bus )
Nikul Shah 8
 Multidimensioanl array means we have to create
array within array.
 example
 <?php
 $a = array("a","b"=>array("train","car"),"bus");
 print_r($a);
 ?>
 Out put.
 Array ( [0] => a [b] => Array ( [0] => train [1] =>
car ) [1] => bus )
Nikul Shah 9
 Create an array by using the elements from
one "keys" array and one "values" array:
 <?php
$fname=array("Peter","Ben","Joe");
$age=array("35","37","43");
$c=array_combine($fname,$age);
print_r($c);
?>
Nikul Shah 10
 This function is for counting the values of an
array.
 <?php
 $no=array(0=>"5",1=>"10",2=>"15",3=>"15
");
 print_r(array_count_values($no));
 ?>
Nikul Shah 11
 Compare the values of two arrays, and return the
differences(difference value is displayes of first
array.)
 <?php
 $animal1=array("a"=>"lion","b"=>"tiger");
 $animal2=array("c"=>"dog","b"=>"tiger");
 $animal3=array("a"=>"cow","g"=>"tiger");
 print_r(array_diff($animal1,$animal3));
 ?>
Nikul Shah 12
 Merge two arrays into one array:
 <?php
 $animal1=array("a"=>"lion","b"=>"tiger");
 $animal2=array("c"=>"dog","d"=>"tiger");
 $animal3=array("a"=>"cow","g"=>"tiger");
 print_r(array_merge($animal1,$animal2,$animal3
));
 ?>
Nikul Shah 13
 Merge two arrays into one array:
 <?php
 $animal1=array("a"=>"lion","b"=>"tiger");
 $animal2=array("c"=>"dog","d"=>"tiger");
 $animal3=array("a"=>"cow","g"=>"tiger");
 print_r(array_merge_recursive($animal1,$animal2
,$animal3));
 ?>
Nikul Shah 14
 Returns an array in the reverse order
 <?php
 $animal1=array("a"=>"lion","b"=>"tiger");
 $animal2=array("c"=>"dog","d"=>"tiger");
 $animal3=array("a"=>"cow","g"=>"tiger");
 print_r(array_reverse($animal1));
 ?>
Nikul Shah 15
 Searches an array for a given value and returns
the key
 <?php
 $animal1=array("a"=>"lion","b"=>"tiger");
 $animal2=array("c"=>"dog","d"=>"tiger");
 $animal3=array("a"=>"cow","g"=>"tiger");
 print_r(array_search("lion"$animal1));
 ?>
Nikul Shah 16
 The array_sum() function returns the sum of
all the values in the array.
 <?php
$a=array(5,15,25);
echo array_sum($a);
?>
Nikul Shah 17
 This function sorts an associative array in desending
order, according to the value.
 <?php
 $animal1=array("a"=>"lion","b"=>"tiger","c"=>"dog","d
"=>"tiger");
 $animal2=array("c"=>"dog","d"=>"tiger");
 $animal3=array("a"=>"cow","g"=>"tiger");
 arsort($animal1);
 foreach ($animal1 as $key =>$val)
 {
 echo "$key = $val"."<br>";
 }
 ?>
Nikul Shah 18
 This function sorts an associative array in ascending order,
according to the value
 <?php
 $animal1=array("a"=>"lion","b"=>"tiger","c"=>"dog","d"=
>"tiger");
 $animal2=array("c"=>"dog","d"=>"tiger");
 $animal3=array("a"=>"cow","g"=>"tiger");
 asort($animal1);
 foreach ($animal1 as $key =>$val)
 {
 echo "$key = $val"."<br>";
 }
 ?>
Nikul Shah 19
 This function sorts an associative array in desending order,
according to the key.
 <?php
 $animal1=array("a"=>"lion","b"=>"tiger","c"=>"dog","d"=>"tiger
");
 $animal2=array("c"=>"dog","d"=>"tiger");
 $animal3=array("a"=>"cow","g"=>"tiger");
 arsort($animal1);
 foreach ($animal1 as $key =>$val)
 {
 echo "$key = $val"."<br>";
 }
 ?>
Nikul Shah 20
 This function sorts an associative array in ascending order,
according to the key
 <?php
 $animal1=array("a"=>"lion","b"=>"tiger","c"=>"dog","d"=
>"tiger");
 $animal2=array("c"=>"dog","d"=>"tiger");
 $animal3=array("a"=>"cow","g"=>"tiger");
 asort($animal1);
 foreach ($animal1 as $key =>$val)
 {
 echo "$key = $val"."<br>";
 }
 ?>
Nikul Shah 21
 This function is to find out no. of elements in an
array.
 <?php
 $animal1=array("a"=>"lion","b"=>"tiger","c"=>"d
og","d"=>"tiger");
 $animal2=array("c"=>"dog","d"=>"tiger");
 $animal3=array("a"=>"cow","g"=>"tiger");
 asort($animal1);
 print_r(sizeof($animal1));
 ?>
Nikul Shah 22
 Removes the first element from an array and returns the
value of the removed element.
 <?php
 $animal1=array("a"=>"lion","b"=>"tiger","c"=>"dog","d"=
>"tiger");
 $animal2=array("c"=>"dog","d"=>"tiger");
 $animal3=array("a"=>"cow","g"=>"tiger");
 echo array_shift($animal1);
 echo "<br>";
 print_r($animal1);

 ?>
Nikul Shah 23
 Return an array of random keys:
 <?php
 $input=array("a","b","c","d","e","f","g","h",);
 $rand_keys = array_rand($input,2);
 echo $input[$rand_keys[0]]."n";
 echo $input[$rand_keys[1]]."n";
 ?>
Nikul Shah 24
 array_push() function inserts one or more
elements to the end of an array.
 You can add one value, or as many as you
like.
 Even if your array has string keys, your added
elements will always have numeric keys.
Nikul Shah 25
 <?php
 $a=array("a"=>"tree",'b'=>"car");
 array_push($a,"bike","activa");
 print_r($a);
 ?>
Nikul Shah 26
 array_pop() function deletes the last element
of an array.
 <?php
 $a=array("tree","car","bike");
 array_pop($a);
 print_r($a);
 ?>
Nikul Shah 27
Ad

More Related Content

What's hot (20)

Php string function
Php string function Php string function
Php string function
Ravi Bhadauria
 
PHP - Introduction to File Handling with PHP
PHP -  Introduction to  File Handling with PHPPHP -  Introduction to  File Handling with PHP
PHP - Introduction to File Handling with PHP
Vibrant Technologies & Computers
 
PHP Form Validation Technique
PHP Form Validation TechniquePHP Form Validation Technique
PHP Form Validation Technique
Morshedul Arefin
 
Database Connectivity in PHP
Database Connectivity in PHPDatabase Connectivity in PHP
Database Connectivity in PHP
Taha Malampatti
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
Madishetty Prathibha
 
Java threads
Java threadsJava threads
Java threads
Prabhakaran V M
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
eShikshak
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
Google
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
Information Technology
 
Arrays
ArraysArrays
Arrays
SARITHA REDDY
 
Variable scope in php
Variable scope in phpVariable scope in php
Variable scope in php
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
Smriti Jain
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
Taha Malampatti
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
Tanmoy Barman
 
Php
PhpPhp
Php
Ajaigururaj R
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
Zeeshan Ahmed
 
Java Collections
Java  Collections Java  Collections
Java Collections
Kongu Engineering College, Perundurai, Erode
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
WebStackAcademy
 
PHP Loops and PHP Forms
PHP  Loops and PHP FormsPHP  Loops and PHP Forms
PHP Loops and PHP Forms
M.Zalmai Rahmani
 

Viewers also liked (16)

Php array
Php arrayPhp array
Php array
Core Lee
 
PHP Unit 4 arrays
PHP Unit 4 arraysPHP Unit 4 arrays
PHP Unit 4 arrays
Kumar
 
PHP array 1
PHP array 1PHP array 1
PHP array 1
Mudasir Syed
 
Php array
Php arrayPhp array
Php array
argusacademy
 
PHP Basic & Arrays
PHP Basic & ArraysPHP Basic & Arrays
PHP Basic & Arrays
M.Zalmai Rahmani
 
Array in php
Array in phpArray in php
Array in php
Ashok Kumar
 
Synapseindia reviews on array php
Synapseindia reviews on array phpSynapseindia reviews on array php
Synapseindia reviews on array php
saritasingh19866
 
03 Php Array String Functions
03 Php Array String Functions03 Php Array String Functions
03 Php Array String Functions
Geshan Manandhar
 
PHP Functions & Arrays
PHP Functions & ArraysPHP Functions & Arrays
PHP Functions & Arrays
Henry Osborne
 
Php Using Arrays
Php Using ArraysPhp Using Arrays
Php Using Arrays
mussawir20
 
Array in php
Array in phpArray in php
Array in php
ilakkiya
 
Arrays in PHP
Arrays in PHPArrays in PHP
Arrays in PHP
Vineet Kumar Saini
 
PHP: Arrays
PHP: ArraysPHP: Arrays
PHP: Arrays
Mario Raul PEREZ
 
PHP Arrays
PHP ArraysPHP Arrays
PHP Arrays
Mahesh Gattani
 
Php ppt
Php pptPhp ppt
Php ppt
Sanmuga Nathan
 
Class 4 - PHP Arrays
Class 4 - PHP ArraysClass 4 - PHP Arrays
Class 4 - PHP Arrays
Ahmed Swilam
 
Ad

Similar to Php array (20)

Chapter 2 wbp.pptx
Chapter 2 wbp.pptxChapter 2 wbp.pptx
Chapter 2 wbp.pptx
40NehaPagariya
 
Unit 2-Arrays.pptx
Unit 2-Arrays.pptxUnit 2-Arrays.pptx
Unit 2-Arrays.pptx
mythili213835
 
Lecture 5 array in PHP.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 5 array in PHP.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 5 array in PHP.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 5 array in PHP.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
ZahouAmel1
 
Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...
Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...
Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...
Dhivyaa C.R
 
UNIT IV (4).pptx
UNIT IV (4).pptxUNIT IV (4).pptx
UNIT IV (4).pptx
DrDhivyaaCRAssistant
 
Array functions using php programming language.pptx
Array functions using php programming language.pptxArray functions using php programming language.pptx
Array functions using php programming language.pptx
NikhilVij6
 
Array functions for all languages prog.pptx
Array functions for all languages prog.pptxArray functions for all languages prog.pptx
Array functions for all languages prog.pptx
Asmi309059
 
Array String - Web Programming
Array String - Web ProgrammingArray String - Web Programming
Array String - Web Programming
Amirul Azhar
 
Java script arrays
Java script arraysJava script arrays
Java script arrays
Frayosh Wadia
 
Java script arrays
Java script arraysJava script arrays
Java script arrays
Frayosh Wadia
 
9780538745840 ppt ch06
9780538745840 ppt ch069780538745840 ppt ch06
9780538745840 ppt ch06
Terry Yoast
 
Arrays in php
Arrays in phpArrays in php
Arrays in php
Laiby Thomas
 
Using arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing informationUsing arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing information
Nicole Ryan
 
Introduction to php 6
Introduction to php   6Introduction to php   6
Introduction to php 6
pctechnology
 
Marcs (bio)perl course
Marcs (bio)perl courseMarcs (bio)perl course
Marcs (bio)perl course
BITS
 
Array Methods.pptx
Array Methods.pptxArray Methods.pptx
Array Methods.pptx
stargaming38
 
4.1 PHP Arrays
4.1 PHP Arrays4.1 PHP Arrays
4.1 PHP Arrays
Jalpesh Vasa
 
Intoduction to php arrays
Intoduction to php arraysIntoduction to php arrays
Intoduction to php arrays
baabtra.com - No. 1 supplier of quality freshers
 
PHP Array Functions.pptx
PHP Array Functions.pptxPHP Array Functions.pptx
PHP Array Functions.pptx
KirenKinu
 
New SPL Features in PHP 5.3
New SPL Features in PHP 5.3New SPL Features in PHP 5.3
New SPL Features in PHP 5.3
Matthew Turland
 
Lecture 5 array in PHP.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 5 array in PHP.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 5 array in PHP.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 5 array in PHP.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
ZahouAmel1
 
Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...
Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...
Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...
Dhivyaa C.R
 
Array functions using php programming language.pptx
Array functions using php programming language.pptxArray functions using php programming language.pptx
Array functions using php programming language.pptx
NikhilVij6
 
Array functions for all languages prog.pptx
Array functions for all languages prog.pptxArray functions for all languages prog.pptx
Array functions for all languages prog.pptx
Asmi309059
 
Array String - Web Programming
Array String - Web ProgrammingArray String - Web Programming
Array String - Web Programming
Amirul Azhar
 
9780538745840 ppt ch06
9780538745840 ppt ch069780538745840 ppt ch06
9780538745840 ppt ch06
Terry Yoast
 
Using arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing informationUsing arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing information
Nicole Ryan
 
Introduction to php 6
Introduction to php   6Introduction to php   6
Introduction to php 6
pctechnology
 
Marcs (bio)perl course
Marcs (bio)perl courseMarcs (bio)perl course
Marcs (bio)perl course
BITS
 
Array Methods.pptx
Array Methods.pptxArray Methods.pptx
Array Methods.pptx
stargaming38
 
PHP Array Functions.pptx
PHP Array Functions.pptxPHP Array Functions.pptx
PHP Array Functions.pptx
KirenKinu
 
New SPL Features in PHP 5.3
New SPL Features in PHP 5.3New SPL Features in PHP 5.3
New SPL Features in PHP 5.3
Matthew Turland
 
Ad

Recently uploaded (20)

Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
How to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 SalesHow to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 Sales
Celine George
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
Cultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptxCultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptx
UmeshTimilsina1
 
The History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptxThe History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
UPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guideUPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guide
abmerca
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
How to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 SalesHow to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 Sales
Celine George
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
Cultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptxCultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptx
UmeshTimilsina1
 
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
UPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guideUPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guide
abmerca
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 

Php array

  • 3.  An array is assigned to a single variable, but it can hold dozens of individual pieces of information.  Each individual bit of information, or row, is referred to as an array element.  Within every array element there are two parts: the value, which contains the actual information you want to store, and a unique key which identifies the value.  you will learn later how key palys an importanat role in the process of accessing and manipulating array elements. Nikul Shah 3
  • 4.  Keys can either be non-negative integers or strings.  Array with integers as key are the most common type and known as SCALAR ARRAYs.  Those with key as string are known as ASSOCIATIVE ARRAY. Nikul Shah 4
  • 5.  There are 2 kinds of arrays in php: indexed and associative arrray.  Key of indexed array is integer starts with 0.  Indexed array are used when we identify things with their position.  Associative arrays have strings as keys and behave more like two-columns table.  The first column is key and second is use to access value. Nikul Shah 5
  • 6.  Numeric array  Associative Array  Multidimensional Array. Nikul Shah 6
  • 7.  In numeric array have to create only elements, id will be automatically assigned to the elements. example <?php $a = array("train", "car","bus"); print_r($a); ?> output  Array ( [0] => train [1] => car [2] => bus ) Nikul Shah 7
  • 8.  In associative array we have create element with id.  example  <?php  $a = array("6"=>"train","7"=>"car","8"=>"bus");  print_r($a);  ?>  Out put.  Array ( [6] => train [7] => car [8] => bus ) Nikul Shah 8
  • 9.  Multidimensioanl array means we have to create array within array.  example  <?php  $a = array("a","b"=>array("train","car"),"bus");  print_r($a);  ?>  Out put.  Array ( [0] => a [b] => Array ( [0] => train [1] => car ) [1] => bus ) Nikul Shah 9
  • 10.  Create an array by using the elements from one "keys" array and one "values" array:  <?php $fname=array("Peter","Ben","Joe"); $age=array("35","37","43"); $c=array_combine($fname,$age); print_r($c); ?> Nikul Shah 10
  • 11.  This function is for counting the values of an array.  <?php  $no=array(0=>"5",1=>"10",2=>"15",3=>"15 ");  print_r(array_count_values($no));  ?> Nikul Shah 11
  • 12.  Compare the values of two arrays, and return the differences(difference value is displayes of first array.)  <?php  $animal1=array("a"=>"lion","b"=>"tiger");  $animal2=array("c"=>"dog","b"=>"tiger");  $animal3=array("a"=>"cow","g"=>"tiger");  print_r(array_diff($animal1,$animal3));  ?> Nikul Shah 12
  • 13.  Merge two arrays into one array:  <?php  $animal1=array("a"=>"lion","b"=>"tiger");  $animal2=array("c"=>"dog","d"=>"tiger");  $animal3=array("a"=>"cow","g"=>"tiger");  print_r(array_merge($animal1,$animal2,$animal3 ));  ?> Nikul Shah 13
  • 14.  Merge two arrays into one array:  <?php  $animal1=array("a"=>"lion","b"=>"tiger");  $animal2=array("c"=>"dog","d"=>"tiger");  $animal3=array("a"=>"cow","g"=>"tiger");  print_r(array_merge_recursive($animal1,$animal2 ,$animal3));  ?> Nikul Shah 14
  • 15.  Returns an array in the reverse order  <?php  $animal1=array("a"=>"lion","b"=>"tiger");  $animal2=array("c"=>"dog","d"=>"tiger");  $animal3=array("a"=>"cow","g"=>"tiger");  print_r(array_reverse($animal1));  ?> Nikul Shah 15
  • 16.  Searches an array for a given value and returns the key  <?php  $animal1=array("a"=>"lion","b"=>"tiger");  $animal2=array("c"=>"dog","d"=>"tiger");  $animal3=array("a"=>"cow","g"=>"tiger");  print_r(array_search("lion"$animal1));  ?> Nikul Shah 16
  • 17.  The array_sum() function returns the sum of all the values in the array.  <?php $a=array(5,15,25); echo array_sum($a); ?> Nikul Shah 17
  • 18.  This function sorts an associative array in desending order, according to the value.  <?php  $animal1=array("a"=>"lion","b"=>"tiger","c"=>"dog","d "=>"tiger");  $animal2=array("c"=>"dog","d"=>"tiger");  $animal3=array("a"=>"cow","g"=>"tiger");  arsort($animal1);  foreach ($animal1 as $key =>$val)  {  echo "$key = $val"."<br>";  }  ?> Nikul Shah 18
  • 19.  This function sorts an associative array in ascending order, according to the value  <?php  $animal1=array("a"=>"lion","b"=>"tiger","c"=>"dog","d"= >"tiger");  $animal2=array("c"=>"dog","d"=>"tiger");  $animal3=array("a"=>"cow","g"=>"tiger");  asort($animal1);  foreach ($animal1 as $key =>$val)  {  echo "$key = $val"."<br>";  }  ?> Nikul Shah 19
  • 20.  This function sorts an associative array in desending order, according to the key.  <?php  $animal1=array("a"=>"lion","b"=>"tiger","c"=>"dog","d"=>"tiger ");  $animal2=array("c"=>"dog","d"=>"tiger");  $animal3=array("a"=>"cow","g"=>"tiger");  arsort($animal1);  foreach ($animal1 as $key =>$val)  {  echo "$key = $val"."<br>";  }  ?> Nikul Shah 20
  • 21.  This function sorts an associative array in ascending order, according to the key  <?php  $animal1=array("a"=>"lion","b"=>"tiger","c"=>"dog","d"= >"tiger");  $animal2=array("c"=>"dog","d"=>"tiger");  $animal3=array("a"=>"cow","g"=>"tiger");  asort($animal1);  foreach ($animal1 as $key =>$val)  {  echo "$key = $val"."<br>";  }  ?> Nikul Shah 21
  • 22.  This function is to find out no. of elements in an array.  <?php  $animal1=array("a"=>"lion","b"=>"tiger","c"=>"d og","d"=>"tiger");  $animal2=array("c"=>"dog","d"=>"tiger");  $animal3=array("a"=>"cow","g"=>"tiger");  asort($animal1);  print_r(sizeof($animal1));  ?> Nikul Shah 22
  • 23.  Removes the first element from an array and returns the value of the removed element.  <?php  $animal1=array("a"=>"lion","b"=>"tiger","c"=>"dog","d"= >"tiger");  $animal2=array("c"=>"dog","d"=>"tiger");  $animal3=array("a"=>"cow","g"=>"tiger");  echo array_shift($animal1);  echo "<br>";  print_r($animal1);   ?> Nikul Shah 23
  • 24.  Return an array of random keys:  <?php  $input=array("a","b","c","d","e","f","g","h",);  $rand_keys = array_rand($input,2);  echo $input[$rand_keys[0]]."n";  echo $input[$rand_keys[1]]."n";  ?> Nikul Shah 24
  • 25.  array_push() function inserts one or more elements to the end of an array.  You can add one value, or as many as you like.  Even if your array has string keys, your added elements will always have numeric keys. Nikul Shah 25
  • 26.  <?php  $a=array("a"=>"tree",'b'=>"car");  array_push($a,"bike","activa");  print_r($a);  ?> Nikul Shah 26
  • 27.  array_pop() function deletes the last element of an array.  <?php  $a=array("tree","car","bike");  array_pop($a);  print_r($a);  ?> Nikul Shah 27
  翻译: