以下是一个使用PHP实现嵌套集合的实例。在这个例子中,我们将创建一个包含多个对象的数组,每个对象又包含一个数组。

```php

实例php嵌套集合,PHP嵌套集合实例教程  第1张

// 创建一个对象类

class Product {

public $name;

public $price;

public $categories;

// 构造函数

public function __construct($name, $price, $categories) {

$this->name = $name;

$this->price = $price;

$this->categories = $categories;

}

}

// 创建一个产品数组

$products = [

new Product("