My Report

PHP Array Test – 1


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. Which function returns an array consisting of associative key/value pairs?

2. What will be the output of the following PHP code?

    <?php
    $states = array("Karnataka" => array
    ("population" => "11,35,000", "capital" => "Bangalore"),
    "Tamil Nadu" => array( "population" => "17,90,000",
    "capital" => "Chennai") );
    echo $states["Karnataka"]["population"];
    ?>

3. Which of the following are correct ways of creating an array?

i) state[0] = "karnataka";
ii) $state[] = array("karnataka");
iii) $state[0] = "karnataka";
iv)  $state = array("karnataka");

4. Which of the following PHP function will return true if a variable is an array or false if it is not an array?

5. What will be the output of the following PHP code?

    <?php
    $fruits = array ("apple", "orange", array ("pear", "mango"),
    "banana");
    echo (count($fruits, 1));
    ?> 

6. Which of the following function is used to get the value of the previous element in an array?

7. Which in-built function will add a value to the end of an array?

8. What will be the output of the following PHP code?

    <?php
    $state = array ("Karnataka", "Goa", "Tamil Nadu",
    "Andhra Pradesh");
    echo (array_search ("Tamil Nadu", $state) );
    ?>

9. What will be the output of the following PHP code?

    <?php
    $fruits = array ("apple", "orange", "banana");
    echo (next($fruits));	
    echo (next($fruits));
    ?>

10. PHP's numerically indexed array begin with position ___________


 

Start practicing “1000 MCQs on PHP”, and once you are ready, you can take tests on all topics by attempting our “PHP Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.