3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User { public $username; public $binders; function __construct($username, $binders) { $this->username = $username; $this->binders = $binders; } } class Binder { public $name; public $contents; function __construct($name, $contents = array()) { $this->name = $name; $this->contents = $contents; } } class Card { public $id; public $quantity; function __construct($id, $quantity = 0) { $this->id = $id; $this->quantity = $quantity; } } $users = array ( 'TestName' => new User ( 'TestName', array ( 'BinderName1' => new Binder ( 'BinderName1', array ( 'CardID_1' => new Card('1', '20'), 'CardID_3' => new Card('3', '10'), ) ), 'BinderName2' => new Binder ( 'BinderName2', array ( 'CardID_1' => new Card('1', '7') ) ) ) ) ); print_r($users); $users['TestName']->binders['BinderName1']->contents['CardID_1']->quantity = 5; print_r($users);

preferences:
54.07 ms | 402 KiB | 5 Q