- print_r: documentation ( source)
- array_filter: documentation ( source)
- get_object_vars: documentation ( source)
<?php
class A
{
private $test1 = 'hello';
protected $test2 = 'world';
protected $test3;
public function toArray()
{
$this->test1 = null;
$this->test3 = false;
$array = get_object_vars($this);
return array_filter($array, 'strlen');
}
}
$a = new A();
print_r(array_filter(array(1,2,false,null), 'strlen')); exit();
print_r($a->toArray());