__set/__get with array properties
<p>Wondering if it's possible to do something like the following (I know the code won't work as intended, just trying to get the purpose across):</p>

<pre><code>class Form
{
    private $v = array();

    function __set($varName, $varValue)
    {
        ... do some treatment on the varValue ...
        $this-&gt;v[$varName] = $varValue;
    }

    function &amp;__get($varName)
    {
        if(!isset($this-&gt;v[$varName]))
            $this-&gt;v[$varName] = NULL;

        return $this-&gt;v[$varName];
    }
};
</code></pre>

<p>I want to be able to set a variable like:</p>

<p><code>$form-&gt;Values['whatever'] = 'dirty';</code></p>

<p>and have it run through the setter function which would call some cleaning operations and actually end up filling a couple other arrays like 'HtmlValues' and 'SqlValues' so I can just pull the values encoded for the format I want, so I can later call</p>

<p><code>echo $form-&gt;HtmlValues['whatever'];</code></p>

<p>The problem is of course the normal issue that if you just use _<em>get, you get end up setting a value that's returned, and even though &amp;</em>_get returns it by reference and thing kind of work, __set is never actually called, even though you're setting a private member.</p>

<p>So basically, I'm wondering if there's a way to call a function on a value whenever you set it within an array (potentially multiple arrays deep and what not like <code>$form-&gt;Values['group']['item'] = 'whatever';</code></p>

<p>The desired output would be something like:</p>

<pre><code>$form-&gt;Values['name'] = "&amp;";
echo $form-&gt;HtmlValues['name']; = &amp;amp;
</code></pre>

<p>(Just to reinforce, I'm not looking for the actual encoding, just the ability to call it on every variable as it's set/changed without having to encode the entire array manually)</p>
