String Manipulation in PHP
String manipulation in PHP is used to manipulate strings, such as concatenating strings, searching for a substring, and replacing a substring.
For example, a simple function that takes two strings and returns the concatenated string:
function concat($str1, $str2) {
return $str1 . $str2;
}
In this example, the function concat() is declared and takes two strings, $str1 and $str2. The function will then return the concatenated string of the two parameters. The output of this function when called with the parameters “Hello” and “World” would be “HelloWorld”.