0

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?

1 Answer 1

1

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"
]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.