Snippet Name: Split all chars in string
Description: Split out all of the characters in a string.
Comment: (none)
Language: PHP
Highlight Mode: PHP
Last Modified: February 28th, 2009
|
<?PHP
// Make the function
FUNCTION Split_String($String) {
// Get the String Length
$STR_LEN = STRLEN($String);
// To prevent notice errors
$New_String = "";
// Loop for each character
FOR ($i = 0; $i < $STR_LEN; $i++) {
// Set it to a variable, you can also echo it...
$New_String .= $String{$i} . "<br />";
}
// Return the new variable
RETURN $New_String;
}
// Set the text to be split
$text = "test test test lol...";
// Echo the outputs of what the function does
ECHO Split_String($text);
?> |