我有带有setter和getter的对象
class obj{
private $a;
private $b;
}我想创建一个仅获取对象值的数组,例如
array = ["1","2"]尝试了get_object_vars,但它是一个关联数组
发布于 2017-08-03 23:57:24
要将关联数组压缩为索引数组,请使用array_values
array_values(get_object_vars($object));但是,如果您有private成员变量,那么您可能只想使用数组强制转换而不是get_object_vars
array_values((array)$object);https://stackoverflow.com/questions/45489161
复制相似问题