how to read "test" in "dir"?
$_USERS = array (
10 => array (
`name` => `xyz`,
`role` => `user`,
`dir` => `["test","test1"]`,),
);
how to read "test" in "dir"?
$_USERS = array (
10 => array (
`name` => `xyz`,
`role` => `user`,
`dir` => `["test","test1"]`,),
);
Assuming you are creating this array statically in your script, I would advise against using the ` quotation. Instead use a single or double quotation.
The below example works the way I believe you are requesting:
$_USERS = array (
10 => array (
"name" => 'xyz',
"role" => 'user',
"dir" => '["test","test1"]',),
);
echo json_decode($_USERS[10]["dir"])[0];
Because the array in "dir" is not a real array, we can translate it into a PHP array by using json_decode.