to_array
Wrap data in an array
Definition
array[any] to_array(any $data)
Wraps $data
in an array, unless $data
is already an array.
Parameters
any $data
Data to wrap into an array.
Returns
array[any]
An array containing $data
, except if $data
is an array, in which case returns $array
.
Examples
{
a: to_array(`null`),
b: to_array(`1`),
c: to_array('text'),
d: to_array(`{name: 'Jane'}`),
e: to_array(`[]`),
f: to_array(`[1, 2, 3]`)
}
{
"a": [null],
"b": [1],
"c": ["text"],
"d": [{"name": "Jane"}],
"e": [],
"f": [1, 2, 3]
}
Updated about 1 year ago