How can PHP substr() function be utilized effectively in string manipulation?
The PHP substr() function can be effectively utilized in string manipulation to extract a portion of a string based on a specified start position and length. This can be useful for tasks such as truncating text, extracting specific parts of a string, or manipulating substrings within a larger string.
// Example usage of PHP substr() function
$string = "Hello, World!";
$substring = substr($string, 7, 5); // Extracts "World" starting from position 7 with a length of 5
echo $substring; // Output: World