In what scenarios would using substr() be a better choice than regular expressions for string manipulation in PHP?

Using substr() would be a better choice than regular expressions for string manipulation in PHP when you need to extract a specific portion of a string based on its position or length. Substr() is more efficient and easier to understand for simple substring extraction tasks, while regular expressions are better suited for more complex pattern matching operations.

// Using substr() to extract a specific portion of a string
$string = "Hello, World!";
$substring = substr($string, 7, 5); // Extracts "World" starting from position 7 with a length of 5
echo $substring;