Home / CSE MCQs / PHP MCQs :: Arrays - PHP

CSE MCQs :: PHP MCQs

  1. Which of the functions is used to sort an array in descending order?
  2. A.
    sort()
    B.
    asort()
    C.
    rsort()
    D.
    dsort()

  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. A.
    (iii) and (iv)
    B.
    (ii) and (iii)
    C.
    Only (i)
    D.
    (ii), (iii) and (iv)

  5. What will be the output of the following php code?
    < ?php      $states = array("karnataka" => array     ( "population" => "11,35,000", "captial" => "Bangalore"),     "Tamil Nadu" => array( "population" => "17,90,000",     "captial" => "Chennai") );     echo  $states["karnataka"]["population"]; ?>
  6. A.
    karnataka 11,35,000
    B.
    11,35,000
    C.
    population 11,35,000
    D.
    karnataka population

  7. Which function will return true if a variable is an array or false if it is not?
  8. A.
    this_array()
    B.
    is_array()
    C.
    do_array()
    D.
    in_array()

  9. Which in-built function will add a value to the end of an array?
  10. A.
    array_unshift()
    B.
    into_array()
    C.
    inend_array()
    D.
    array_push()

  11. 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) ); ?>
  12. A.
    True
    B.
    1
    C.
    False
    D.
    2

  13. What will be the output of the following PHP code?
    < ?php      $fruits = array ("apple", "orange", "banana");     echo (next($fruits));	     echo (next($fruits)); ?>
  14. A.
    orangebanana
    B.
    appleorange
    C.
    orangeorange
    D.
    appleapple

  15. Which function can be used to move the pointer to the previous array position?
  16. A.
    last()
    B.
    before()
    C.
    prev()
    D.
    previous()

  17. What will be the output of the following PHP code?
    < ?php      $fruits = array ("apple", "orange", array ("pear", "mango"),     "banana");     echo (count($fruits, 1)); ?>
  18. A.
    3
    B.
    4
    C.
    5
    D.
    6

  19. Which function returns an array consisting of associative key/value pairs?
  20. A.
    count()
    B.
    array_count()
    C.
    array_count_values()
    D.
    count_values()