PHP Arrays and Array Functions – MCQs

MCQ Paper

1. Which of the following is a correct way to define an indexed array in PHP?





2. How do you access the first element of an indexed array $fruits = array("apple", "banana", "cherry");?





3. Which array type uses named keys that you assign manually?





4. What is the output of the following?

      $person = array("name" => "John", "age" => 30);   
		echo $person["age"]; 
      




5. What is a multidimensional array in PHP?





6. Which function counts all elements in an array?





7. What does array_keys($array) return?





8. How do you loop through an associative array in PHP?





9. Which function merges two arrays in PHP?





10. What is the result of in_array("blue", $colors) if $colors = array("red", "blue", "green")?





Wait for 20 seconds...

Post a Comment

Previous Post Next Post