String Handling - searching, replacing, formatting, string library functions - One Line Questions

1. What is the difference between `strpos()` and `stripos()` in PHP? `strpos()` is case-sensitive, `stripos()` is case-insensitive.
2. What is the main difference between `strstr()` and `strchr()`? `strstr()` searches for a substring, `strchr()` searches for a character.
3. What is the output of `strrev('hello')`? 'olleh'
4. What does `sha1()` generate? A SHA-1 hash of a string.
5. What does `str_word_count()` return by default? The number of words in the string.
6. The `wordwrap()` function in PHP is used to: Wrap a string to a specified number of characters.
7. What does `md5()` function do in PHP? Generates an MD5 hash of a string.
8. Which function splits a string by another string? explode()
9. What does `str_contains()` check for? If a string contains a specific substring.
10. The `substr_replace()` function can replace part of a string with another string. What is the default behavior if the length parameter is omitted? It replaces until the end of the original string.
11. Which function removes whitespace from the beginning and end of a string? trim()
12. Which function is used to remove characters from the beginning of a string? ltrim()
13. Which function is used to parse a string into variables? parse_str()
14. What does `str_ireplace()` do? Performs a case-insensitive string replacement.
15. Which function is used to convert a string into an array by splitting it on lines? preg_split('/\r\n|\n|\r/', $string)
16. What does `str_rot13()` do? Applies the ROT13 cipher to a string.
17. Which function pads a string to a certain length with another string? str_pad()
18. Which function is used to replace all occurrences of a substring with another substring in PHP? str_replace()
19. The `str_ireplace()` function performs a case-insensitive version of which function? str_replace()
20. To check if a string starts with a specific substring, which function is most suitable? str_starts_with()
21. Which function compares two strings or parts of strings from a specified starting point? substr_compare()
22. Which function compares two strings using a 'natural order' algorithm? strnatcmp()
23. Which function is used to get the length of a string in characters, supporting multi-byte encodings? mb_strlen()
24. Which function is used to get the length of a string in bytes? strlen()
25. Which PHP function is used to find the position of the first occurrence of a substring within a string? strpos()
26. Which function is used to find the position of the first occurrence of a substring, ignoring case? stripos()
27. Which function returns the last occurrence of a substring in a string? strrpos()
28. Which function returns the position of the last occurrence of a substring, ignoring case? strripos()
29. Which function returns a part of a string, starting from a specified position? substr()
30. Which function returns the string with all characters converted to lowercase? strtolower()
31. Which function translates or replaces characters in a string? strtr()
32. Which function returns the string representation of a variable? strval()
33. Which function is used to get a substring of a string, starting from a specified offset and with a specified length, ignoring case? substr_compare()
34. Which function returns a string, obtained by inserting a string into another string at a specified position? substr_replace()
35. Which function returns the portion of a string starting from a specified offset up to a specified length? substr()
36. What does the PHP function `strlen()` return? The length of the string in bytes.
37. The `substr_count()` function returns: The number of occurrences of a substring.
38. What does `levenshtein()` calculate? The Levenshtein distance between two strings.
39. What is the purpose of `str_pad()`? To add characters to a string until it reaches a specified length.
40. What is the purpose of `implode()` in PHP? To join array elements into a string with a glue string.
41. What is the primary function of `str_replace()`? To replace all occurrences of a search string with a replacement string.
42. What is the primary role of `sscanf()`? To parse a string according to a specified format.
43. What is the primary purpose of the `explode()` function in PHP? To split a string into an array by a delimiter.
44. What is the purpose of `strip_tags()`? To remove HTML and PHP tags from a string.
45. What is the purpose of `str_repeat()`? To repeat a string a specified number of times.
46. What is the primary use of `str_shuffle()`? To randomly shuffle the characters of a string.
47. Which PHP function converts a string to all uppercase letters? strtoupper()
48. Which function returns the string with the first character of each word capitalized? ucwords()
49. Which function returns the string with the first character of the string capitalized? ucfirst()
50. The `str_split()` function in PHP divides a string into an array of: Substrings of a specified length