How can substrings be used in PHP to extract specific sections of text for further processing?

Substrings in PHP can be used to extract specific sections of text by specifying the starting position and length of the desired substring. This can be useful for tasks such as extracting a portion of a string for further processing or manipulation.

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