formating a string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



i have a 12 digit code that i want to format as follows xxxx-xxxx-xxxx it is 
all numbers i tried using substr() to format it in this fassion
$code = abcdwxyz8765;
$string = array();
$string[] = substr($code,1,4);
$string[] = substr($code,5,8);
$string[] = substr($code9,12);
echo $string[0],'-',$string[1],'-',$string[2];
OUTPUT SHOULD BE : abcd-wxyz-5678
I GET : -wxyz678-5678
Any help? 

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux