PHP Sorting Arrays


  1. What will be the output of the following PHP code?
    <?php
    $num = array ("Zero","One", "Two", "Three", "Four","Five");
    $subset = array_slice ($num, 2);
    print_r ($subset);
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    The array_slice() function returns a section of an array based on a starting and ending offset value.


  1. What will be the output of the following PHP code?
    <?php
    $num = array ("Zero","One", "Two", "Three", "Four","Five");
    $subset = array_splice ($num, 3);
    print_r ($subset);
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    The array_splice() function removes all elements of an array found within a specified range.



  1. What will be the output of the following PHP code?
    <?php
    $n = array ("16", "Interview Mania", 10, "4");
    echo (array_sum ($n));
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    The array_sum() function add all the values of the input array together, returning the final sum. If a string datatype is found, it’ll be ignored.