join_hide
TABLE OF CONTENTS
Join strings from an array with a given separator, ignoring null and whitespace
Definition
string join_hide(string $separator, array[string] $stringsarray)
Joins strings from $stringsarray with $separator in between them, ignoring null and whitespace.
Parameters
string $separator
Separator to use between elements of $stringsarray.
array[string] $stringsarray
Array of strings to be joined.
Returns
string
Single string consisting of all non-null, non-whitespace elements from $stringsarray with $separator in between them.
Examples
{
a: join_hide(', ', ['dragon', 'fruit']),
b: join_hide('', ['dragon', 'fruit']),
c: join_hide('', ['dragon', ' ',`null`, 'fruit']),
d: join_hide(', ', [`1.0`,`false`]),
e: join_hide(', ', [`1.1`]),
f: join_hide(' - ', [`null`]),
g: join_hide(', ',`[]`),
h: join_hide(', ',`{dragon: 'fruit'}`)
}{
"a": "dragon, fruit",
"b": "dragonfruit",
"c": "dragonfruit",
"d": "1, False",
"e": "1.1",
"f": "",
"g": "",
"h": ""
}Remarks
This function acts identically to join, except that it ignores null and whitespace array elements.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article