It's not exactly a duplicate and the answer is not whatever @Alive_to_Die wrote - it sets the array index into exactly named class property, whilst the question is something else...
You will have to manually remap indexes into class properties.
class obj
{
public $myName;
public $yourName;
}
$array = [
'my_name' => 'Xavi',
'your_name' => 'Luis',
];
$obj = new obj;
$obj->myName = $array['my_name'];
$obj->yourName = $array['your_name'];
var_dump($obj);
Output:
object(obj)#1 (2) {
["myName"]=>
string(4) "Xavi"
["yourName"]=>
string(4) "Luis"
}