How can PHP functions be utilized to manipulate and extract data from complex patterns?

To manipulate and extract data from complex patterns in PHP, regular expressions can be used. Regular expressions are patterns used to match character combinations in strings. PHP functions like preg_match() and preg_replace() can be utilized to work with regular expressions and extract or manipulate data based on these patterns.

// Example of using preg_match() to extract data from a complex pattern
$string = "My phone number is 123-456-7890";
$pattern = '/(\d{3})-(\d{3})-(\d{4})/';
preg_match($pattern, $string, $matches);
echo "Phone number: " . $matches[0]; // Output: Phone number: 123-456-7890