Extract number and periods from string in php
Posted: 28 Oct 2020, 13:59
I have a string with numbers and periods. For example '123456...'
I want to separate 123456 and ... and still get the number and the period in php.
I tried using preg_replace():
With the code above I can extract the numbers but I can't extract the periods. Is there any other way to extract the periods?
I want to separate 123456 and ... and still get the number and the period in php.
I tried using preg_replace():
Code: Select all
$numbers = preg_replace('/[^0-9]/', '', '123456...');
$period = preg_replace('/./', '', '123456...);