Cara mengakses array di php

Array di PHP adalah jenis struktur data yang memungkinkan kita untuk menyimpan banyak elemen dari tipe data yang serupa di bawah satu variabel sehingga menghemat upaya untuk membuat variabel yang berbeda untuk setiap data. Array berguna untuk membuat daftar elemen dengan tipe serupa, yang dapat diakses menggunakan indeks atau kuncinya. Misalkan kita ingin menyimpan lima nama dan mencetaknya sesuai dengan itu. Ini dapat dengan mudah dilakukan dengan menggunakan lima variabel string yang berbeda. Tetapi jika bukannya lima, angkanya naik menjadi seratus, maka akan sangat sulit bagi pengguna atau pengembang untuk membuat begitu banyak variabel yang berbeda. Di sini array berperan dan membantu kita menyimpan setiap elemen dalam satu variabel dan juga memungkinkan akses mudah menggunakan indeks atau kunci. Array dibuat menggunakan fungsi array() di PHP

Pada dasarnya ada tiga jenis array di PHP.  

  • Array Berindeks atau Numerik. Array dengan indeks numerik tempat nilai disimpan secara linear
  • Array asosiatif. Array dengan indeks string di mana alih-alih penyimpanan linier, setiap nilai dapat diberi kunci tertentu
  • Array Multidimensi. Array yang berisi array tunggal atau ganda di dalamnya dan dapat diakses melalui banyak indeks

Array Berindeks atau Numerik

Jenis array ini dapat digunakan untuk menyimpan semua jenis elemen, tetapi indeks selalu berupa angka. Secara default, indeks dimulai dari nol. Array ini dapat dibuat dengan dua cara berbeda seperti yang ditunjukkan pada contoh berikut.  

PHP




<?php

 

// One way to create an indexed array

$name_one =

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
0
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
2
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
4
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
6
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
8________0______3_______10_____10_____10_____1

 

Accessing the elements directly:
zara
sara
any
Rani
Ravina
_2

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Accessing the elements directly:
zara
sara
any
Rani
Ravina
4
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3 $name_one
Accessing the elements directly:
zara
sara
any
Rani
Ravina
8
Accessing the elements directly:
zara
sara
any
Rani
Ravina
9
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3 $name_one
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
3
Accessing the elements directly:
zara
sara
any
Rani
Ravina
9
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3 $name_one
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
8
Accessing the elements directly:
zara
sara
any
Rani
Ravina
9
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

 

Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
1

Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
2
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
3
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
4
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
2
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
7
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
8
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
2
Dave Punk
mob : 2584369721
email : [email protected]

John Flinch
mob : 9875147536
email : [email protected]
1
Dave Punk
mob : 2584369721
email : [email protected]

John Flinch
mob : 9875147536
email : [email protected]
2
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
2
Dave Punk
mob : 2584369721
email : [email protected]

John Flinch
mob : 9875147536
email : [email protected]
5
Dave Punk
mob : 2584369721
email : [email protected]

John Flinch
mob : 9875147536
email : [email protected]
6
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
2
Dave Punk
mob : 2584369721
email : [email protected]

John Flinch
mob : 9875147536
email : [email protected]
9<?php0
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

 

Accessing the elements directly:
zara
sara
any
Rani
Ravina
_2

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3 <?php4
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
2
Accessing the elements directly:
zara
sara
any
Rani
Ravina
8
Accessing the elements directly:
zara
sara
any
Rani
Ravina
9
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
2
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
3
Accessing the elements directly:
zara
sara
any
Rani
Ravina
9
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
2
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
8
Accessing the elements directly:
zara
sara
any
Rani
Ravina
9
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

 

$name_one_1

Keluaran.  

Accessing the 1st array elements directly:
Ram
Zack
Raghav
Accessing the 2nd array elements directly:
RAM
ZACK
RAGHAV

Melintasi. Kita dapat melintasi array yang diindeks menggunakan loop di PHP. Kita dapat mengulang array yang diindeks dengan dua cara. Pertama dengan menggunakan for loop dan kedua dengan menggunakan foreach. Anda bisa merujuk ke PHP. Loop untuk sintaks dan penggunaan dasar.  

Contoh.   

PHP




<?php

 

$name_one_3

$name_one =

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
0
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
2
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
4
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
6
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
8________0______3_______10_____10_____10_____1

 

=_8

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
00
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
02
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1$name_one
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
05
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
06
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
07

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
06
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
11
Accessing the elements directly:
zara
sara
any
Rani
Ravina
9
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
_14

 

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
_15

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
_16

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
17 =
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
19
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1$name_one
Accessing the elements directly:
zara
sara
any
Rani
Ravina
1

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
24
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

 

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
_26

Accessing the elements directly:
zara
sara
any
Rani
Ravina
_3
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
28
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
30
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
32
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
33
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
32
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
35
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
17
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
32________0______39

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Accessing the elements directly:
zara
sara
any
Rani
Ravina
3 $name_one
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
43
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
32
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
45
Accessing the elements directly:
zara
sara
any
Rani
Ravina
9
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
_14

 

$name_one_1

Keluaran.  

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV

Array asosiatif

Jenis array ini mirip dengan array yang diindeks tetapi alih-alih penyimpanan linier, setiap nilai dapat ditetapkan dengan kunci tipe string yang ditentukan pengguna.  

Contoh.   

PHP




<?php

 

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
_51

$name_one =

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
0
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
2
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
58
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
4
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57________0______62
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
64
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
6
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
67
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
8
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
71
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
64
Accessing the elements directly:
zara
sara
any
Rani
Ravina
0
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
76
Accessing the elements directly:
zara
sara
any
Rani
Ravina
1

 

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
_78

Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
2
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
43
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
81
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
82
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
83
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
2
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
43
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
87
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
82
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
89
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

________28______2

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
43
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
93
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
82
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
95
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
2
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
43
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
99
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
82
Accessing the elements directly:
zara
sara
any
Rani
Ravina
01
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
2
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
43
Accessing the elements directly:
zara
sara
any
Rani
Ravina
05
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
82
Accessing the elements directly:
zara
sara
any
Rani
Ravina
07
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

 

Accessing the elements directly:
zara
sara
any
Rani
Ravina
_2

Accessing the elements directly:
zara
sara
any
Rani
Ravina
_3
Accessing the elements directly:
zara
sara
any
Rani
Ravina
11
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
2
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
43
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
81
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
45
Accessing the elements directly:
zara
sara
any
Rani
Ravina
9
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
2
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
43
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
99
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
45
Accessing the elements directly:
zara
sara
any
Rani
Ravina
9
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
2
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
43
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
87
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
45
Accessing the elements directly:
zara
sara
any
Rani
Ravina
9
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3 $name_one
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
43
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
6
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
45
Accessing the elements directly:
zara
sara
any
Rani
Ravina
9
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3 $name_one
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
43
Accessing the elements directly:
zara
sara
any
Rani
Ravina
0
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
45
Accessing the elements directly:
zara
sara
any
Rani
Ravina
9
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

 

$name_one_1

Keluaran.  

Accessing the elements directly:
zara
sara
any
Rani
Ravina

Melintasi Array Asosiatif. Kita dapat melintasi array asosiatif dengan cara yang sama seperti dalam array numerik menggunakan loop. Kita dapat mengulang array asosiatif dengan dua cara. Pertama dengan menggunakan for loop dan kedua dengan menggunakan foreach. Anda bisa merujuk ke PHP. Loop untuk sintaks dan penggunaan dasar.  

Contoh.   

PHP




<?php

 

Accessing the elements directly:
zara
sara
any
Rani
Ravina
_50

$name_one =

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
0
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
2
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
58
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
4
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57________0______62
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3

Accessing the elements directly:
zara
sara
any
Rani
Ravina
63
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
6
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
67
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
8
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
71
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3

Accessing the elements directly:
zara
sara
any
Rani
Ravina
63
Accessing the elements directly:
zara
sara
any
Rani
Ravina
0
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
76
Accessing the elements directly:
zara
sara
any
Rani
Ravina
1

 

Accessing the elements directly:
zara
sara
any
Rani
Ravina
_77

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
00
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
02
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1$name_one
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
05
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
06
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Accessing the elements directly:
zara
sara
any
Rani
Ravina
87
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
07

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Accessing the elements directly:
zara
sara
any
Rani
Ravina
91
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
11
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
06
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
11
Accessing the elements directly:
zara
sara
any
Rani
Ravina
95
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
11
Accessing the elements directly:
zara
sara
any
Rani
Ravina
87__________0______11________10____1______5

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
_14

 

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
02

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
04
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

________21______06 =

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
08
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
2
Accessing the elements directly:
zara
sara
any
Rani
Ravina
1

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
17 =
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
19
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
2
Accessing the elements directly:
zara
sara
any
Rani
Ravina
1

 

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
30
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
20
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
21
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
20
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
35
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
17
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
21_______25
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
20________21______27

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
06
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
43
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
20
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
_______
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
_____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________F

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
_14

 

$name_one_1

Keluaran.  

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina

Array Multidimensi

Array multi-dimensi adalah array yang menyimpan array lain di setiap indeks, bukan satu elemen. Dengan kata lain, kita dapat mendefinisikan array multidimensi sebagai array dari array. Seperti namanya, setiap elemen dalam array ini bisa menjadi array dan mereka juga bisa menampung sub-array lain di dalamnya. Array atau sub-array dalam array multidimensi dapat diakses menggunakan banyak dimensi.  

Contoh.   

PHP




<?php

 

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
_47

________21______48 =

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
0
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
0
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
55
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
56
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
58________0______3

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
55
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
61
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
63________0______3

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
55
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
66
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
68
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
71

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
0
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
55
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
56
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
78
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
55
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
61
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
83________0______3

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
55
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
66
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
88
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
71

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
0
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
55
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
56
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
98
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
55
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
61
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
03________0______3

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
55
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
66
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
08
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
11

Accessing the elements directly:
zara
sara
any
Rani
Ravina
_1

 

Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
_13

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
15
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
11
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
48
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
18
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
66
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
45
Accessing the elements directly:
zara
sara
any
Rani
Ravina
9
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
24
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
11
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
48
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
27
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
61
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
29

 

$name_one_1

Keluaran.  

Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536

Melintasi Array Multidimensi. Kita dapat melintasi array multidimensi menggunakan for dan foreach loop dengan cara bersarang. Artinya, satu untuk loop untuk array luar dan satu untuk loop untuk array dalam

Contoh.   

PHP




<?php

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
_47

________21______48 =

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
0
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
58
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
0
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
55
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
61
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
63________0______3

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
55
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
66
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
68
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
71

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
58
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
0
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
55
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
61
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
83________0______3

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
55
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
66
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
88
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
71

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
98
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
0
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
55
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
61
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
03________0______3

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
55
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
66
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
57
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
08
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
3

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
11

Accessing the elements directly:
zara
sara
any
Rani
Ravina
_1

 

Dave Punk email-id is: [email protected]
John Flinch mobile number is: 9875147536
_89

________21______06 =

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
08
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
48
Accessing the elements directly:
zara
sara
any
Rani
Ravina
1

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
30
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
20
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
33
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
20
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
35
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
19
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
48_______
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
_1________21_____38____0

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
06
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
43
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
20
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
33
Accessing the elements directly:
zara
sara
any
Rani
Ravina
9
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
02
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
1
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
48
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
43
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
06
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
43
Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
___________________________________________________5
Dave Punk
mob : 2584369721
email : [email protected]

John Flinch
mob : 9875147536
email : [email protected]
__________________________________________________________________________________________________________________________________________________

Looping using foreach: 
Husband is Zack and Wife is Zara
Husband is Anthony and Wife is Any
Husband is Ram and Wife is Rani
Husband is Salim and Wife is Sara
Husband is Raghav and Wife is Ravina

Looping using for: 
zack zara
anthony any
ram rani
salim sara
raghav ravina
55
Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Dave Punk
mob : 2584369721
email : [email protected]

John Flinch
mob : 9875147536
email : [email protected]
26
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
11________38______34
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
11
Dave Punk
mob : 2584369721
email : [email protected]

John Flinch
mob : 9875147536
email : [email protected]
28
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
11
Accessing the elements directly:
zara
sara
any
Rani
Ravina
9
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
14

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
08
Accessing the elements directly:
zara
sara
any
Rani
Ravina
3
Accessing the elements directly:
zara
sara
any
Rani
Ravina
9
Accessing the elements directly:
zara
sara
any
Rani
Ravina
5

Looping using foreach: 
Zack
Anthony
Ram
Salim
Raghav

The number of elements is 5 
Looping using for: 
ZACK
ANTHONY
RAM
SALIM
RAGHAV
_14

 

$name_one_1

Keluaran.  

Dave Punk
mob : 2584369721
email : [email protected]

John Flinch
mob : 9875147536
email : [email protected]

Artikel ini disumbangkan oleh Chinmoy Lenka. Jika Anda menyukai GeeksforGeeks dan ingin berkontribusi, Anda juga dapat menulis artikel menggunakan tulis. geeksforgeeks. org atau kirimkan artikel Anda ke review-team@geeksforgeeks. org. Lihat artikel Anda muncul di halaman utama GeeksforGeeks dan bantu Geeks lainnya
Silakan tulis komentar jika Anda menemukan sesuatu yang salah, atau Anda ingin berbagi informasi lebih lanjut tentang topik yang dibahas di atas
 

PHP adalah bahasa skrip sisi server yang dirancang khusus untuk pengembangan web. Anda dapat mempelajari PHP dari bawah ke atas dengan mengikuti Tutorial PHP dan Contoh PHP ini

Bagaimana cara mengakses kunci array di PHP?

Jika Anda memiliki nilai dan ingin menemukan kuncinya, gunakan array_search() seperti ini. $arr = array('pertama' => 'a', 'kedua' => 'b', ); .

Bagaimana Anda mengakses array?

Mengakses Elemen Array . Indeks array dimulai dari 0 dan diakhiri dengan ukuran-1. nama_array[indeks]; . use the name of the array name followed by the index of the element in square brackets. Array indices start at 0 and end at size-1: array_name[index]; accesses the index'th element of array_name starting at zero.

Bagaimana cara membuat dan mengakses array di PHP?

Sangat mudah untuk membuat larik dalam skrip PHP. Untuk membuat array, Anda menggunakan konstruksi array(). $myArray = array( values ​​); Untuk membuat array terindeks, cukup cantumkan nilai array di dalam tanda kurung, dipisahkan dengan koma.

Bagaimana cara memanggil array di PHP?

Untuk membuat array di PHP, kita menggunakan fungsi array array(). Secara default, array variabel apa pun dimulai dengan indeks 0. Jadi, setiap kali Anda ingin memanggil nilai pertama dari sebuah array, Anda mulai dengan 0 kemudian selanjutnya adalah 1. dan seterusnya. .
Array Numerik/Terindeks
Array asosiatif
Array Multidimensi