PHP Strings
- What will be the output of the following PHP code?
<?php
$url = "interview@mania.com";
echo ltrim(strstr($url, "@"),"@");
?>
-
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.
- What will be the output of the following PHP code?
$cars = array("Datsun", "Jeep", "Lada", "Spyker");
$car = preg_grep("/^L/", $cars);
print_r($car);
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
This function is used to search an array for foods beginning with s.
- Say we have two compare two strings which of the following function/functions can you use?
-
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.
- Which one of the following functions will convert a string to all uppercase?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Its prototype follows string strtoupper(string str).
- What will be the output of the following PHP code?
<?php
echo str_pad("Salad", 10)." is good.";
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
The str_pad() function pads a string with a specified number of characters.