array agg php to array

Solutions on MaxInterview for array agg php to array by the best coders in the world

showing results for - "array agg php to array"
Rayan
15 Feb 2020
1
2// Postgresql arrays look like this: {1,2,3,4}
3$x = '{1,2,3,4}';
4$y = json_decode('[' . substr($x, 1, -1) . ']');  // [1, 2, 3, 4]
5
6
7
8// To cast back the other way would be mirror opposite:
9$y = [1, 2, 3, 4];
10$x = '{' . substr(json_encode($y), 1, -1) . '}';
similar questions
queries leading to this page
array agg php to array