How can you extract only the first number from a house number using preg_match in PHP?

To extract only the first number from a house number using preg_match in PHP, you can use a regular expression to match the first number in the string. You can achieve this by using the preg_match function with the regular expression pattern "/\d+/" to match the first number in the string.

$houseNumber = "123A";
preg_match('/\d+/', $houseNumber, $matches);
$firstNumber = $matches[0];
echo $firstNumber; // Output: 123