我想将对象键转换为数组键。 例如我的密钥如data.row.key进入[“data”] [“row”] [“key”]

I Want to convert object keys into array keys. For example my keys like data.row.key into ["data"]["row"]["key"];

I want to an array format ["data"]["row"]["key"]

Thanks in Advance

I am not sure what you exactly want but if your intention is to convert string to array format use the below code.

$key = 'data.row.key';
// explode it
$key_array = explode('.',$key);
$array_key_format = '';
foreach($key_array as $key) {
    $array_key_format .= '["'.$key.'"]';
}

echo $array_key_format;

Out Put:

["data"]["row"]["key"]

The out put is only string, cannot be used as array.