timmah1 Posted March 21, 2008 Share Posted March 21, 2008 How do I display just a certain number of characters from a database? I cc info stored into a database, I only want to display the last 6 characters, how do I get it to display like this: xxxx-xxxx-xx12-3456 Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/97230-simple-question/ Share on other sites More sharing options...
BlueSkyIS Posted March 21, 2008 Share Posted March 21, 2008 $cc_num = "4111234598762223"; $new_num = "xxxx-xxxx-xx".substr($cc_num,-6,2)."-".substr($cc_num,-4); echo $new_num; Link to comment https://forums.phpfreaks.com/topic/97230-simple-question/#findComment-497512 Share on other sites More sharing options...
timmah1 Posted March 21, 2008 Author Share Posted March 21, 2008 Perfect! I used this //$cleanedstr = substr_replace($original, "", 0, ; //$cleanedstr2 = substr_replace($cleanedstr, "XXXXXXXXXXXX", -12, 4); But i like yours better Thank you Link to comment https://forums.phpfreaks.com/topic/97230-simple-question/#findComment-497520 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.