Reputation: 1797
I use tagify plugin. In my Laravel application controller I try to get tags:
code:
$tags = $request->tags;
result: (returned as string)
[ { value: "css" }, { value: "dfs" } ]
I tried $tags = json_decode($tags);
to convert to array. This returns below result:
[
{
value: "css"
},
{
value: "dfs"
}
]
I just need css and dfs (no need value: and double quotes). How to get these?
Upvotes: 0
Views: 273
Reputation: 11034
Here's what you can do using Laravel's collections
$json = '[ { "value": "css" }, { "value": "dfs" } ]';
$json = json_decode($json);
return collect($json)->pluck('value')->toArray();
Results:
[
"css",
"dfs"
]
Upvotes: 1