A
A
Anatoly2018-05-19 13:44:16
PHP
Anatoly, 2018-05-19 13:44:16

How to get the last 10 digits from a string?

Good afternoon!
Tell me how to get the last 10 digits from a string with a regular expression?
for example, there are phone numbers 87771234567 the output should be 7771234567
or +77771234567 the output should be - 7771234567

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yan-s, 2018-05-19
@les-anatoliy

mykolaim

$input = "87771234567";
$output = substr($input, -10);

echo $output;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question