You need to replace a certain word in a string in your PHP script. How would you do this?
- str_replace($search, $replacement, $string)
- replace($search, $replacement, $string)
- substr_replace($search, $replacement, $string)
- swap($search, $replacement, $string)
To replace a certain word in a string in PHP, you can use the str_replace() function. The str_replace() function performs a search and replace operation on a given string. It replaces all occurrences of the specified search string with the replacement string. Pass the search string, replacement string, and the original string as arguments to the str_replace() function, like this: str_replace($search, $replacement, $string). This will return a new string with the replaced word. Learn more: https://www.php.net/manual/en/function.str-replace.php
Loading...
Related Quiz
- Is it possible to use COM components in PHP?
- What are some common uses of the function_exists() function in PHP?
- You have a PHP script and you need to read a file. How would you do this?
- In PHP, integers can be specified in decimal (base 10), hexadecimal (base 16), octal (base 8), and ______ (base 2) format.
- A destructor in a PHP class is defined using the __destruct() method.