I have something like this:
JavaScript
x
return Model::get()->pluck('count','column');
Result:
{"ABC":1,"DEF":3,"GHI":1,"JKL":2}
How to separate the ‘column’ and ‘count’ into variables?
JavaScript
$column = ["ABC","DEF","GHI","JKL"];
$count = [1,3,1,2];
Advertisement
Answer
Use native PHP functions; array_keys
and array_values
.
JavaScript
$result = Model::get()->pluck('count', 'column');
$column = array_keys($result);
$count = array_values($result);
For more details, read the below links;