Ole Sauffaus
Ole Sauffaus

Reputation: 534

PHP Object-nested data manipulation

I have two classes, A and B, that work together, like this:

QUESTION:

How do I manipulate Carray from global scope, without copying it, AND without explicitly pointing at A->B->C for each operation?

PS: This is a minimal example. My chains could end up rather long, if no solution exists.

Upvotes: 2

Views: 101

Answers (1)

ptkoz
ptkoz

Reputation: 2497

Use a reference. You will have to use A->B->C only once per scope.

$c = &$A->b->c;
$c['something'] = 'somethiing else';

Upvotes: 1

Related Questions