Split All Chars In String

Description: Split out all of the characters in a string.

// 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);

Enjoyed this post? Share it!


Leave a comment

Your email address will not be published.