Which of the following are correct ways of creating an array?
1. state[0] = “karnataka”;
2. $state[] = array(“karnataka”);
3. $state[0] = “karnataka”;
4. $state = array(“karnataka”);
A. 3 and 4
B. 2 and 3
C. Only 1
D. 2, 3 and 4
Answer: Option A
Solution (By Examveda Team)
A variable name should start with $ symbol which is not present in i) and you need not put the square brackets when you use the array() constructor.Join The Discussion
Comments (1)
Related Questions on Arrays
A. karnataka 11,35,000
B. 11,35,000
C. population 11,35,000
D. karnataka population
Which function will return true if a variable is an array or false if it is not?
A. this_array()
B. is_array()
C. do_array()
D. in_array()

Answer 2 is legit also. You would be creating an array with single string value 'karnataka' as a value inside the array $state