LPC Library Functions: implode

NAME

implode() - combine elements of an array

SYNOPSIS

string implode( array arr, string del );

mixed implode( array arr, function f);

mixed implode( array arr, function f, mixed start);

DESCRIPTION

Concatenate all strings found in array 'arr', with the string 'del' between each element. Only strings are used from the array. Elements that are not strings are ignored.

The second version takes the first and second elements of 'arr' and passes them to 'f', then passes the result of 'f' and the third element of 'arr' to 'f', and so on. It returns the last result of the call to 'f'.

In the third version, the first call is f(start, arr[0]), then things proceed as described for the second version.

Example:

string *my_array = ({ "now","is","the","time" });
int *my_nums = ({ 1, 2, 3 });

function add_nums(int a, int b) { return a+b; }

implode(my_array," ") returns "now is the time"

implode(my_nums, f) returns 6

implode(my_nums, f, 11) returns 17

SEE ALSO

explode(), sprintf()

Page design by Frank Jacquette & Tim Hollebeek
Copyright (C) 1998 Tim Hollebeek & Frank Jacquette
Back to MudOS