How does one declare an array .. i know dersz no declaration in php just want more insight on array in php | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How does one declare an array .. i know dersz no declaration in php just want more insight on array in php

php

6th Oct 2017, 1:24 PM
Shalom Inimfon Uwem
Shalom Inimfon Uwem - avatar
3 Answers
0
u can declare an array like dis in php $myarr = array(); note d above is an empty array. assign values to d array like dis $myarr[]= 'maths'; $myarr[]= 'english'; $myarr[] = 'chemistry'; access d values like dis echo $myarr[0]; prints out maths cuz it is d first item inside d array and arrays are indexed from 0. D above example is an indexed array.
6th Oct 2017, 2:31 PM
Otuokwu Israel
Otuokwu Israel - avatar
0
thanks
6th Oct 2017, 6:09 PM
Shalom Inimfon Uwem
Shalom Inimfon Uwem - avatar
- 1
Numberic array $a = Array (0, 1, 2); or $a = [0, 1, 2]; Associative Array $a = Array ("foo" => "bar", "bar" => "baz"); or $a ["foo" => "bar", "bar" => "baz"];
6th Oct 2017, 5:16 PM
Freezemage
Freezemage - avatar