"Riddler" <ri*********@hotmail.com> wrote in message
news:66********************************@4ax.com...
Anyone have an idea about how I could go about writing a function that
would simply insert a character inbetween each character in a string?
For instance:
HELLO WORLD
would turn into:
H E L L O W O R L D
My brain hurts from thinking about this one but I'm stumped.
Thanks!
Tested:
<?php
function addspaces( $str ) {
$temp = array();
for ( $i = 0; $i < strlen( $str ); $i++ ) {
$temp[$i] = $str[$i].' ';
}
$temp = implode( '', $temp );
$temp = str_replace( ' ', ' ', $temp );
return $temp;
}
print addspaces( 'testing testing 123' );
?>
HTH
- JP