Okay, Im trying to make a small function that would take a string such as $foo = "string"; and convert that to $foo = "s+t+r+i+n+g"; Basily breakdown the string and put it together adding a character inbetween each character of the string.
Anyideas?
Thanks
Breaking up strings and adding character inbetween.
Moderator: General Moderators
-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm
Code: Select all
function strBreak($string, $separator)
{
$length = strlen($string);
$letters = array();
for ($i = 0; $i < $length; $i++)
{
$letter = substr($string, $i, 1);
array_push($letters, $letter);
}
return implode($separator, $letters);
}
echo strBreak('string', '+');-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm