Answers for "array_agg php to array"

PHP
0

array_agg php to array

// Postgresql arrays look like this: {1,2,3,4}
$x = '{1,2,3,4}';
$y = json_decode('[' . substr($x, 1, -1) . ']');  // [1, 2, 3, 4]



// To cast back the other way would be mirror opposite:
$y = [1, 2, 3, 4];
$x = '{' . substr(json_encode($y), 1, -1) . '}';
Posted by: Guest on August-24-2021

Browse Popular Code Answers by Language