Php 从对象中检索值

Php 从对象中检索值,php,arrays,object,Php,Arrays,Object,由于空间原因,我无法从[Create Table]中获取值 我创建这样的对象 $create_table = DB::select('SHOW CREATE TABLE '.$table_name)[0]; 这就是这个物体看起来的样子 stdClass Object ( [Table] => contact_monitor [Create Table] => CREATE TABLE `contact_monitor` ( `contact_id`

由于空间原因,我无法从[Create Table]中获取值

我创建这样的对象

$create_table = DB::select('SHOW CREATE TABLE '.$table_name)[0];
这就是这个物体看起来的样子

stdClass Object
(
    [Table] => contact_monitor
    [Create Table] => CREATE TABLE `contact_monitor` (
        `contact_id` int(11) DEFAULT NULL,
        `monitor_id` int(11) NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1
)

但是,我可以使用
$create\u Table->Table

从[Table]中获取值,只需使用
{}
大括号访问带有空格的属性:

echo $create_table->{'Create Table'}; // this will also work on hyphenated properties as well

@itsliamoco当然没问题!很高兴这有帮助