ubuntu-user Posted September 23, 2009 Share Posted September 23, 2009 Hello I need to format a string: 2100001b32121501 to: 21:00:00:1b:32:12:15:01 i.e. I need to insert a colon very second character. How do I do this? Thank you. Link to comment https://forums.phpfreaks.com/topic/175230-help-with-formatting-a-string/ Share on other sites More sharing options...
thebadbad Posted September 23, 2009 Share Posted September 23, 2009 One way of doing it: <?php $str = '2100001b32121501'; $str = implode(':', str_split($str, 2)); ?> Link to comment https://forums.phpfreaks.com/topic/175230-help-with-formatting-a-string/#findComment-923575 Share on other sites More sharing options...
ubuntu-user Posted September 23, 2009 Author Share Posted September 23, 2009 Thank you. That is perfect. Link to comment https://forums.phpfreaks.com/topic/175230-help-with-formatting-a-string/#findComment-923581 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.