Strings Flashcards
1
Q
How can you remove all whitespace from a string?
A
trim($str);
2
Q
How can you repeat a string?
A
str_repeat($str, 5)
3
Q
How to find the first occurrence of a specified letter in a string and how do you find the last occurrence of a specified letter?
A
strpos($str, ‘b’);
strrchr($str, ‘b’)
4
Q
How can you turn a string in to an array with each word as an item? How can you turn an array into a string with a space between each item in array?
A
explode(‘ ‘, $str);
implode(‘ ‘, $str);