You are currently viewing the GMLscripts.com static mirror. Forum access and script submissions are not available through this mirror.

Invert GMLscripts.com

string_add_spaces

Returns given string with spaces inserted between each character.

s = string_add_spaces("spaces");        //  "s p a c e s"
s = string_add_spaces("hello, world");  //  "h e l l o ,   w o r l d"
s = string_add_spaces("");              //  ""
s = string_add_spaces("1");             //  "1"
s = string_add_spaces("12");            //  "1 2"
string_add_spaces(str)
Returns given string with spaces inserted between each character.
COPY/// @func   string_add_spaces(str)
///
/// @desc   Returns given string with spaces inserted between each character.
///
/// @param  {string}    str         string to insert spaces into
///
/// @return {string}    string with spaces inserted
///
/// GMLscripts.com/license

function string_add_spaces(str)
{
    var len = string_length(str);
    for (var j = len; j > 1; j--) {
        str = string_insert(" ", str, j);
    }
    return str;
}

Contributors: Legolas710, xot

GitHub: View · Commits · Blame · Raw