如何在 PHP 中将(转换)对象转换为没有类名前缀的数组?
class Teste{
private $a;
private $b;
function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
}
var_dump((array)(new Teste('foo','bar')));
结果:
array
'�Teste�a' => string 'foo' (length=3)
'�Teste�b' => string 'bar' (length=3)
预期的:
array (
a => 'foo'
b => 'bar' )