PHP Arrays


  1. What will be the output of the following PHP code ?
    <?php
    $Emp1 = array("Ajit", "Rahul");
    $Emp2 = array("Ats", "Aju");
    print_r(array_replace($Emp1, $Emp2));
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    The array_replace() function replaces the values of the first array with the values from following arrays


  1. What will be the output of the following PHP code?
    <?php
    $Flower = array("Rose", "Lily", "Sunflower");
    echo "I like " . $Flower[0] . ", " . $Flower[1] . " and " . $Flower[2] . ".";
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    The array() function is used to create an array.



  1. What will be the output of the following PHP code?
    <?php
    $Profile = array("Ajit"=>"22", "Ats"=>"23", "Aju"=>"24");
    print_r(array_change_key_case($Profile, CASE_UPPER));
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    The array_change_key_case() function changes all keys in an array to lowercase or uppercase.


  1. What will be the output of the following PHP code?
    <?php
    $Flower = array("Daffodil", "Dahlia", "Daisy", "Daphne", "Delphinium", "Dianella");
    print_r(array_chunk($Flower, 3));
    ?>













  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    The array_chunk() function splits an array into chunks of new arrays.



  1. What will be the output of the following PHP code?
    <?php
    $EmpName = array("Ajit Kumar Gupta", "Ats Yogi", "Aju Jayaraj");
    $Salary = array("35000", "37000", "43000");
    $Result = array_combine($EmpName, $Salary);
    print_r($Result);
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    The array_combine() function creates an array by using the elements from one “keys” array and one “values” array