0

From a php script I'm requesting the keys of a JSON field in a MySQL 8++ database (table) using the JSON_KEYS(specs), which works fine. The result is a string like this $json_keys = '["KEY1", "KEY2", "KEY3", "KEY4"]'

Is there a quick way to convert this into a php array ?

Today i'm doing this $myArray = explode(', ',str_replace(array('[',']','"'), '',$json_keys)); But there must be a better and smarter way to do it.

1 Answer 1

0

I think the best answer is

$myArray = json_decode ($json_keys)

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.