What are the best practices for extracting specific parts of a string and storing them in variables in PHP?

When extracting specific parts of a string in PHP, you can use functions like `substr`, `strpos`, or regular expressions to isolate the desired substring. Once you have extracted the substring, you can store it in a variable for further processing or manipulation.

$string = "Hello World";
$substring = substr($string, 0, 5); // Extracts "Hello" from the string
echo $substring; // Outputs "Hello"