What are some common functions or methods in PHP that can be used to manipulate strings?

When working with strings in PHP, there are several built-in functions and methods that can be used to manipulate them. Some common functions include `strlen()` to get the length of a string, `substr()` to extract a portion of a string, `str_replace()` to replace occurrences of a substring, `strtolower()` and `strtoupper()` to convert a string to lowercase or uppercase respectively, and `trim()` to remove whitespace from the beginning and end of a string.

// Example of using common string manipulation functions in PHP
$string = "Hello, World!";

// Get the length of the string
$length = strlen($string);
echo "Length of string: $length\n";

// Extract a portion of the string
$substring = substr($string, 7, 5);
echo "Substring: $substring\n";

// Replace occurrences of a substring
$newString = str_replace("World", "PHP", $string);
echo "Replaced string: $newString\n";

// Convert the string to lowercase
$lowercase = strtolower($string);
echo "Lowercase string: $lowercase\n";

// Remove whitespace from the beginning and end of the string
$trimmedString = trim("   Hello, World!   ");
echo "Trimmed string: $trimmedString\n";