method jsonBase64Encode documentation in bbn\X
Encodes an array's values to the base64 encoding scheme. You can also convert the resulting array into a JSON string (default).
Example
X::jsonBase64Encode(['a' => 'Hello World!', 'b' => 2]);
// (string) '{"a":"SGVsbG8gV29ybGQh","b":2}'
X::jsonBase64Encode(['a' => 'Hello World!'], false);
// (array) ['a' => 'SGVsbG8gV29ybGQh']
function(array $arr, $json = true)
{
$res = [];
foreach ($arr as $i => $a) {
if (is_array($a)) {
$res[$i] = self::jsonBase64Encode($a, false);
}
elseif (is_string($a)) {
$res[$i] = base64_encode($a);
}
else{
$res[$i] = $a;
}
}
return $json ? json_encode($res) : $res;
}
Encodes an array's values to the base64 encoding scheme. You can also convert the resulting array into a JSON string (default). BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions