Hi all,
After searching the forum for an anwser I could not find one, please I need help.
I want to format a string.
The code below works geart; it output a value of "1843341190" as "1 84334 118 2".
function formatStr2($str) {
return $str{0} . "-"
. substr($str, 1, 6) . "-"
. substr($str, 7, 2) . "-"
. $str{9};
}
Now I need to format another string with a value of "333155555 331"as "333 1 55555 333 1". The code I am using is:
function formatStr3($str) {
return $str{0} . "-"
. substr($str, 3, 3) . "-"
. substr($str, 1 1) . "-"
. substr($str, 5, 5) . "-"
. substr($str, 3, 3) . "-"
. substr($str, 1, 1) . "-"
. $str{13};
}
But the results are rubbish, like:-"3---33---55---3-3"
Can someone help with this please.