I am trying to use php to generate a 9 digit number that does not start with 0, and split the dash into every third number.
eg. 102-394-458
I also discuss
Of course, the choice will affect how the number is generated.
implode('-',str_split(rand(100000000,999999999),3))
Generally, it’s better to just store as a number and format it just for display purposes
number_format() -. , "" , - , , .
:
$number = mt_rand(100000000,999999999);
number_format :
echo number_format($number,0,"","-");
1 9. 8 0 9. , , .
( , , .)
,
mt_rand(100000000, 999999999);
wordwrap($number, 3, '-', true);
Source: https://habr.com/ru/post/1757497/More articles:Question about string handling - javaПереслать пользователя на предыдущую страницу после входа в систему - drupalbeanstalkd weirdness, returns invalid jobs - phpMake asynchronous requests synchronous - javaUsing UITapGestureRecognizer to show / hide menus - objective-cDjango, accessing a PostgreSQL sequence - djangoHow to poll for updates using JSONP? - jsonpЛюбые идеи о том, как я могу реализовать grid-view в CSS? - CSS - htmljquery: Insert a set of elements over another set of elements / merge elements - javascriptString formatting problems and line number concatenation - pythonAll Articles