PHP Basics
21. | Which of the following is used to replace a substring in a string in PHP? |
---|
A. str_replace()
B. replace()
C. substr_replace()
D. replace_substr()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The str_replace() function is used to replace a substring in a string in PHP.
22. | Which of the following is used to split a string into an array in PHP? |
---|
A. split()
B. explode()
C. slice()
D. splitstring()
View Answer Discuss Work SpaceAnswer: option b
Explanation:
The explode() function is used to split a string into an array in PHP.
23. | Which of the following is used to sort an array in ascending order in PHP? |
---|
A. sort()
B. asort()
C. ksort()
D. none of the above
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The sort() function is used to sort an array in ascending order in PHP.
24. | Which of the following is used to add an element to the end of an array in PHP? |
---|
A. array_push()
B. array_pop()
C. array_shift()
D. array_unshift()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The array_push() function is used to add an element to the end of an array in PHP.
25. | Which of the following is used to remove the last element from an array in PHP? |
---|
A. array_push()
B. array_pop()
C. array_shift()
D. array_unshift()
View Answer Discuss Work SpaceAnswer: option b
Explanation:
The array_pop() function is used to remove the last element from an array in PHP.