My Report (&Account)

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%)

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

Question 1 of 10 (sanfoundry.com)

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

Question 2 of 10 (sanfoundry.com)

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

Question 3 of 10 (sanfoundry.com)

4. 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");

Question 4 of 10 (sanfoundry.com)

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

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

Question 5 of 10 (sanfoundry.com)

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

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

Question 6 of 10 (sanfoundry.com)

7. 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"];
    ?>

Question 7 of 10 (sanfoundry.com)

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

Question 8 of 10 (sanfoundry.com)

9. 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) );
    ?>

Question 9 of 10 (sanfoundry.com)

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

Question 10 of 10 (sanfoundry.com)


 

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

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
I’m Manish - Founder and CTO at Sanfoundry. I’ve been working in tech for over 25 years, with deep focus on Linux kernel, SAN technologies, Advanced C, Full Stack and Scalable website designs.

You can connect with me on LinkedIn, watch my Youtube Masterclasses, or join my Telegram tech discussions.

If you’re in your 20s–40s and exploring new directions in your career, I also offer mentoring. Learn more here.