What are some potential pitfalls to be aware of when filtering numbers from a string in PHP?
When filtering numbers from a string in PHP, one potential pitfall to be aware of is that certain characters or symbols may be mistakenly treated as part of a number. To avoid this, it's important to use a reliable method to extract only the numerical values from the string. One way to do this is by using regular expressions to match and filter out non-numeric characters.
$string = "abc123def456ghi";
$numbers = preg_replace('/[^0-9]/', '', $string);
echo $numbers;