How can the substr function in PHP be utilized to extract specific parts of a string for processing?

To extract specific parts of a string for processing in PHP, you can use the substr function. This function allows you to specify a starting position and optionally a length to extract a portion of the string. By using substr, you can easily manipulate and work with specific parts of a string in your PHP code.

$string = "Hello, World!";
$substring = substr($string, 7, 5); // Extracts "World" starting from position 7 with a length of 5 characters
echo $substring; // Outputs "World"