What are some alternative methods to extract values from a string in PHP besides using regular expressions and explode?

When extracting values from a string in PHP, besides using regular expressions and explode, you can also use functions like substr, strpos, and str_replace. These functions can help you extract specific parts of a string based on character positions or values.

// Using substr to extract a specific portion of a string
$string = "Hello World";
$extracted = substr($string, 6, 5);
echo $extracted; // Output: World

// Using strpos to find the position of a substring
$string = "Hello World";
$position = strpos($string, "W");
$extracted = substr($string, $position);
echo $extracted; // Output: World

// Using str_replace to extract a value by replacing other characters
$string = "Hello, World";
$extracted = str_replace(",", "", $string);
echo $extracted; // Output: Hello World