Question discussion

Which of the following are correct ways of creating an array?1. state[0] = “karnataka”;2. $state[] = array(“karnataka”);3. $state[0] = “kar…

280619Medium 1 reply 1,192 views
59
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”);
  • A3 and 4
  • B2 and 3
  • COnly 1
  • D2, 3 and 4
Correct answer: A

Discussion 1

0
CCommunity
3 and 4

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.