Answers for "php get all in object as array"

PHP
0

php get all in object as array

$object = new StdClass;
$object->foo = 1;
$object->bar = 2;

var_dump( (array) $object );
Posted by: Guest on October-02-2021
0

php get all in object as array

class Foo
{
    private $foo;
    protected $bar;
    public $baz;

    public function __construct()
    {
        $this->foo = 1;
        $this->bar = 2;
        $this->baz = new StdClass;
    }
}

var_dump( (array) new Foo );
Posted by: Guest on October-02-2021

Code answers related to "php get all in object as array"

Browse Popular Code Answers by Language