1. Question:What is the difference between sizeof($array) and count($array)? 

    Answer
    sizeof($array) - This function is an alias of count()
    count($array) - If you just pass a simple variable instead of an array it will return 1.

    1. Report
  2. Question:What are the different functions in sorting an array? Discuss them?

     

    Answer
    array_reverse():    reverses an array’s element order.

    array_flip(): reverses the roles of the keys and their corresponding values.
        
    sort(): sorts an array, ordering elements from lowest to highest value.

    rsort(): sorts array items in reverse (descending) order.

    asort() : sorting an array in ascending order, except that the key/value correspondence is maintained.

    arsort(): it sorts the array in reverse order maintained key/value co-relation.


    1. Report
  3. Question:Why substr() is used?

     

    Answer
    The substr() function returns the part of a string located between a predefined starting offset and length positions.

    Its prototype : string substr(string str, int start [, int length])


    1. Report
  4. Question:Difference between array_merge() and array_slice()?

     

    Answer

    Array_merge():
    The array_merge() function merges arrays together, returning a single, unified array.

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

    1. Report
  5. Question:Difference between array_merge() and array_slice()?  

    Answer
    Ans: The array_merge() function merges one or more arrays into one array. This function returns one array with the elements of all the parameter arrays.

    The array_slice() function returns selected parts of an array. The array_slice() function returns part of an array as specified by the start and length parameters. If start is a positive number, it means that the ”slice” will start that many elements from the beginning of the array.


    1. Report
  6. Question:How can we automatically escape incoming data? 

    Answer
    We have to enable the Magic quotes entry in the configuration file of PHP.

    1. Report
Copyright © 2024. Powered by Intellect Software Ltd