PHP Arrays


  1. What will be the output of the following PHP code?
    <?php
    $Country = array("India", "England", "USA");
    echo "I like " . $Country[2] . ", " . $Country[1] . " and " . $Country[0] . ".";
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    The order of elements defined.


  1. What will be the output of the following PHP code?
    <?php
    $Student = array("Rahul", "Ajit", "Ats");
    echo $Student[0] . " is the friend of " . $Student[1] . " and " . $Student[2] . ".";
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Simple definition of array and using it in a string. We have used $Student [1],$Student [1] and hence Ajit, Ats appears.



  1. What will be the output of the following PHP code?
    <?php
    $Student = array("Ajit", "Rahul", "Ats");
    echo $names[0] . "is the friend of " . $names[1] . " and " . $names[1] . ".".$friend;
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    $brother undeclared.


  1. What will be the output of the following PHP code?
    <?php
    $Country = array("INDIA", "ENGLAND", "ISRAEL", "USA");
    array_pop($Country);
    print_r($Country);
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    The array_pop() function deletes the last element of an array.



  1. What will be the output of the following PHP code ?
    <?php
    $num = array(2, 15, 20, 1);
    echo(array_product($num));
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    The array_product() function calculates and returns the product of an array.