I have object with setter and getter
class obj{
private $a;
private $b;
}
I would like to create an array that get only the value of the object , for example
array = ["1","2"]
tried get_object_vars but its an associative array
To condense an associative array to an indexed array, use array_values:
array_values(get_object_vars($object));
However, given that you have private member variables, you might just want to use an array cast instead of get_object_vars:
array_values((array)$object);
get_object_varsshould have returned an empty array, not an associative array.array(0 => "1", 1 => "2");orarray('a' => 1, 'b' => 2);