Strings Flashcards

1
Q

How can you remove all whitespace from a string?

A

trim($str);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How can you repeat a string?

A

str_repeat($str, 5)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly