Hi Everyone,
I have a number (say 936 or 1212) I want to count backwards 2 characters and insert a ":" character (which will create a time value actually.
so in my examples i would get 9:36 and 12:12
Your help would be great
Chris
Try http://www.phpbuilder.com/manual/function.strtr.php
$x = array('932', '1245', '705'); foreach ($x as $x) echo substr($x, 0, -2).':'.substr($x, -2, 2).'<br />';
that function is for translating one character to another. I am wanting to insert a character at a specific point.
thanks mrhappiness that did the job! Great! thanks!
There's another way, using a single function, [man]substr_replace/man:
$x = array('932', '1245', '705'); foreach ($x as $str) echo substr_replace($str, ':', -2, 0) . '<br />';