Ajay Pratap Singh Ajay Pratap Singh - 7 months ago 15
PHP Question

Place space or dash between number

I have number

123456789
.
I want to place - between two number till my given number count would not be end.

$nubmer = 1234567890.


output will be
12-34-56-78-90

Answer
function splitNum($num) {
  return implode("-", str_split($num, 2));
}
echo splitNum("1234567890") //output: 12-34-56-78-90