Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding a space between numbers and letters

Tags:

string

php

Is there a way to add a space between numbers and letters in PHP?

Turn these:

14junee Parade
174kinglake 7612Jonh
7612jonh abcde

to

14 junee Parade
174 kinglake 7612 Jonh
7612 jonh abcde
like image 466
Dion Russell Avatar asked Oct 16 '25 21:10

Dion Russell


1 Answers

try this, check the live demo.

echo preg_replace('/(\d+)/', '${1} ', '174kinglake 7612Jonh');
like image 52
LF00 Avatar answered Oct 18 '25 10:10

LF00



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!