Hello ppl,
I have a simple question for you, how can I insert in a string after 4 chars a line "-" and after another 2 another line "-" ??
from xxxxxxxx to xxxx-xx-xx what function I should use ????
10x in advance
see ya
$newdate = multiple [MAN]substr[/MAN]s
Basically like the previous user said you just need to use multiple substrings, like this:
$var="12345678"; $newVar=substr($var,0,4)."-".substr($var,4,2)."-".substr($var,6);
Hope this helps!
Miles
A regex would also work nicely:
<?PHP $foo = "12345678"; $foo = preg_replace("/(.{4})(.{2})(.{2})/", "$1-$2-$3", $foo); ?>
10x alot guys... You gived me the help I need to this simple question 🙂