Add method in an std object in php
===

Peace be upon you!

First of all I apologize if this is a bad question or have already asked. Well please look at following example first

    $arr = array(
        "nid"=> 20,
        "title" => "Something",
        "value" => "Something else",
    );
    $node = (object) $arr;
    $node->another='Another value';
    var_dump($node);
It outputs as expected. Here is an answer on [So][1] about it.

**My question is:** Is it possible to add a method/function in this way, like

    $arr = array(
        "nid"=> 20,
        "title" => "Something",
        "value" => "Something else",
        "my_method" => function($arg){....}
    );
or may be like this

    $node = (object) $arr;
    $node->my_method=function($arg){...};

and if it's possible then how can I use that function/method. Thanks in advance!


  [1]: http://stackoverflow.com/questions/931407/what-is-stdclass-in-php