Вырезать все кроме цифр (PHP)
Вырезать быстро все символы кроме цифр в строке можно при помощи регулярных выражений, например функцией preg_replace().
Например
Есть строка в которое содержатся буквы и цифры, нужно вырезать все кроме цифр.
<?php
$str = 'But I must 123 explain to you 345 how all this 2 mistaken idea of denouncing
pleasu645re and praising pa84in was born and I will give 6you a complete acco87unt
of the system, and 098 expound the actual teachings of the gr42eat explorer of the truth,
the maste64r-bu88ilder of human happi24ness.';
echo preg_replace('/[^0-9]/', '', $str); // 12334526458468709842648824
?>
Комментарии:
Нету комментариев для вывода...