Skip to content

oca-class-a/php-strings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

php-strings

PHP String

  1. php string 1. Write a PHP script to : a) transform a string all uppercase letters. b) transform a string all lowercase letters. c) make a string's first character uppercase. d) make a string's first character of all the words uppercase.

  2. Write a PHP script to split the following string. Sample string : '082307' Expected Output : 08:23:07

  3. Write a PHP script to check whether a string contains a specific string? Sample string : 'The quick brown fox jumps over the lazy dog.' Check whether the said string contains the string 'jumps'.

  4. Write a PHP script to extract the file name from the following string. Sample String : 'www.example.com/public_html/index.php' Expected Output : 'index.php'

  5. Write a PHP script to extract the user name from the following email ID. Sample String : 'Orange@example.com' Expected Output : 'Orange'

  6. Write a PHP script to get the last three characters of a string. Sample String : 'Orange@example.com' Expected Output : 'com'

  7. Write a PHP script to generate simple random passwords [do not use rand() function] from a given string. Sample string : '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcefghijklmnopqrstuvwxyz' Note : Password length may be 6, 7, 8 etc. Expected OutPut: 254ABCc

  8. Write a PHP script to replace the first 'the' of the following string with 'That'. Sample date : 'the quick brown fox jumps over the lazy dog.' Expected Result : That quick brown fox jumps over the lazy dog.

  9. Write a PHP script to find the first character that is different between two strings. String1 : 'football' String2 : 'footboll' Expected Result : First difference between two strings at position 5: "a" vs "o"

  10. Write a PHP script to put a string in an array. Sample strings : "Twinkle, twinkle, little star,\nHow I wonder what you are.\nUp above the world so high,\nLike a diamond in the sky."; Expected Result (using var_dump()) : array(4) { [0]=> string(30) "Twinkle, twinkle, little star," [1]=> string(26) "How I wonder what you are." [2]=> string(27) "Up above the world so high," [3]=> string(26) "Like a diamond in the sky." }

  11. Write a PHP script to print the next character of a specific character. Sample character : 'a' Expected Output : 'b' Sample character : 'z' Expected Output : 'a'

  12. Write a PHP script to remove a part of a string from the beginning. Sample string : 'orange@example.com' Expected Output : 'example.com'

  13. Write a PHP script to insert a string at the specified position in a given string. Original String : 'The brown fox' Insert 'quick' between 'The' and 'brown'. Expected Output : 'The quick brown fox'

  14. Write a PHP script to get the first word of a sentence. Original String : 'The quick brown fox' Expected Output : 'The'

  15. Write a PHP script to remove all leading zeroes from a string. Original String : '000547023.24' Expected Output : '547023.24'

  16. Write a PHP script to remove part of a string. Original String : 'The quick brown fox jumps over the lazy dog' Remove 'fox' from the above string. Expected Output : 'The quick brown jumps over the lazy dog'

  17. Write a PHP script to remove trailing slash from a string. Original String : 'The quick brown fox jumps over the lazy dog///' Expected Output : 'The quick brown fox jumps over the lazy dog'

  18. Write a PHP script to get the characters after the last '/' in an url. Sample URL : 'http://www.example.com/5478631' Expected Output : '5478631'

  19. Write a PHP script to replace Special characters from the following string. Sample String : '"\1+2/32:2-3/43' Expected Output : '1 2 3 2 2 3 4 3'

  20. Write a PHP script to select first 5 words from the following string. Sample String : 'The quick brown fox jumps over the lazy dog' Expected Output : 'The quick brown fox jumps'

  21. Write a PHP script to remove comma(s) from the following numeric string. Sample String : '2,543.12' Expected Output : 2543.12

  22. Write a PHP script to print letters from 'a' to 'z'.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published