Php 取消序列化()后的奇数数组键
所以我有一些这种格式的输出:Php 取消序列化()后的奇数数组键,php,arrays,Php,Arrays,所以我有一些这种格式的输出: array ( 'job' => 'Illuminate\\Queue\\CallQueuedHandler@call', 'data' => array ( 'commandName' => 'App\\Jobs\\SampleJob', 'command' => 'O:21:"App\\Jobs\\SampleJob":5:{s:10:"' . "\0" . '*' . "\0" . 'post";O:45:
array (
'job' => 'Illuminate\\Queue\\CallQueuedHandler@call',
'data' =>
array (
'commandName' => 'App\\Jobs\\SampleJob',
'command' => 'O:21:"App\\Jobs\\SampleJob":5:{s:10:"' . "\0" . '*' . "\0" . 'post";O:45:"Illuminate\\Contracts\\Database\\ModelIdentifier":2:{s:5:"class";s:18:"App\\Models\\Post";s:2:"id";i:28711;}s:10:"connection";N;s:5:"queue";N;s:5:"delay";N;s:6:"' . "\0" . '*' . "\0" . 'job";N;}',
),
)
我需要访问命令下的id
值(28711)
所以我取消了它:
$output = (array) unserialize($event->data['data']['command']);
现在,当我打印这个数组的数组键时,它会给出:
array (
0 => '' . "\0" . '*' . "\0" . 'post',
1 => 'connection',
2 => 'queue',
3 => 'delay',
4 => '' . "\0" . '*' . "\0" . 'job',
)
如何访问第一个键的值?当我尝试取消序列化该数组时,我只得到一个错误(注意)和false
作为输出。当我尝试取消序列化该数组时,我只得到一个错误(注意)和false
作为输出。