N
N
Nubbin2018-02-22 09:57:22
PHP
Nubbin, 2018-02-22 09:57:22

split string?

Good afternoon. Please help with one problem
$string = "J2123409871111222";
how to divide it into 4 parts
J 2123 4098 7111 1222

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DevMan, 2018-02-22
@Nubbin

https://ideone.com/Hay4Pa

A
Anton fon Faust, 2018-02-22
@bubandos

$parts[0] = substr($string, 0, 1);
$parts[1] = substr($string, 1, 4);
$parts[2] = substr($string, 5, 4);
$parts[3] = substr($string, 9, 4);
$parts[4] = substr($string, 13);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question