You can name the function something like get_digits_only
.
Here’s an example implementation:
function get_digits_only($input) {
return preg_replace('/\D/', '', $input);
}
// Example usage:
$string = "Phone: +1 (800) 555-1234";
$digits = get_digits_only($string);
echo $digits; // Output: 18005551234
The name reflects the function’s purpose: extracting only digits from a string.