@ 2015-02-06T21:53:39Z <?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);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 5.0.0 - 5.0.5 , 5.1.0 - 5.1.6 , 5.2.0 - 5.2.17 , 5.3.0 - 5.3.29 , 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.40 , 7.0.0 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 Array
(
[TestName] => User Object
(
[username] => TestName
[binders] => Array
(
[BinderName1] => Binder Object
(
[name] => BinderName1
[contents] => Array
(
[CardID_1] => Card Object
(
[id] => 1
[quantity] => 20
)
[CardID_3] => Card Object
(
[id] => 3
[quantity] => 10
)
)
)
[BinderName2] => Binder Object
(
[name] => BinderName2
[contents] => Array
(
[CardID_1] => Card Object
(
[id] => 1
[quantity] => 7
)
)
)
)
)
)
Array
(
[TestName] => User Object
(
[username] => TestName
[binders] => Array
(
[BinderName1] => Binder Object
(
[name] => BinderName1
[contents] => Array
(
[CardID_1] => Card Object
(
[id] => 1
[quantity] => 5
)
[CardID_3] => Card Object
(
[id] => 3
[quantity] => 10
)
)
)
[BinderName2] => Binder Object
(
[name] => BinderName2
[contents] => Array
(
[CardID_1] => Card Object
(
[id] => 1
[quantity] => 7
)
)
)
)
)
)
Output for 4.4.2 - 4.4.9 Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/p28ma on line 5
Process exited with code 255 . Output for 4.3.0 - 4.3.1 , 4.3.5 - 4.3.11 , 4.4.0 - 4.4.1 Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/p28ma on line 5
Process exited with code 255 . Output for 4.3.2 - 4.3.4 Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/p28ma on line 5
Process exited with code 255 . preferences:dark mode live preview
366.29 ms | 401 KiB | 459 Q