When should you use the substr() function in PHP for string manipulation?
The substr() function in PHP is used for extracting a portion of a string. This can be useful for manipulating strings by getting a specific substring based on a starting position and length. You should use the substr() function when you need to extract a part of a string, such as removing characters from the beginning or middle of a string, or when you need to extract a specific portion of a string for further processing.
$string = "Hello, World!";
$substring = substr($string, 7); // Extracts "World!"
echo $substring;