PHP Strings


  1. What will be the output of the following PHP code?
    <?php
    $url = "interview@mania.com";
    echo ltrim(strstr($url, "@"),"@");
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    The strstr() function returns the remainder of a string beginning with the first occurrence of a predefined string.


  1. What will be the output of the following PHP code?
    $cars = array("Datsun", "Jeep", "Lada", "Spyker");
    $car = preg_grep("/^L/", $cars);
    print_r($car);
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    This function is used to search an array for foods beginning with s.



  1. Say we have two compare two strings which of the following function/functions can you use?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    All of the functions mentioned above can be used to compare strings in some or the other way.


  1. Which one of the following functions will convert a string to all uppercase?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Its prototype follows string strtoupper(string str).



  1. What will be the output of the following PHP code?
    <?php
    echo str_pad("Salad", 10)." is good.";
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    The str_pad() function pads a string with a specified number of characters.