什么是PHP中的对象集合?

时间:2017-01-16 02:49:48

标签: php object collections

我需要创建一个包含对象集合的对象" ticket"。但它是什么?

这是一个具有嵌入对象tickets的对象:

    stdClass Object
(
    [email] => asd@asd.ru
    [phone] => +79243000155
    [tickets] => stdClass Object
        (
            [ticketType] => Adult
            [person] => Array
                (
                    [fullName] => John Doe
                    [FirstName] => John
                )
        )
)

tickets必须表示为对象集合。它应该如何形成并创建?

1 个答案:

答案 0 :(得分:0)

对于PHP,试试这个:

$array = array(
    "email" => "asd@asd.ru",
    "phone" => "+79243000155",
    "tickets" => array(
         "ticketType" => "Adult",
         "person" => array(
             "fullName" => "John Doe",
             "FirstName" => "John"
          )
     )
 );