Pre: See this answer for a discussion on using stdClass or an array for holding representative data.
Answer:
The first way is very bad, in that you are adding needless overhead in converting an array to an object (when you could use the array for that purpose).
The second way works, but is not ideal. It does not truly treat the object (in code) as you would treat an object (in life), and therefore does not fit the object-oriented paradigm. (However, it does seem to be the best option for this situation, as per the comments.)
The best way (from an OO perspective) is to define the object class.
Example definition:
class Contact{
public $name;
public $phone;
public $email;
function __construct($name, $phone, $email) {
$this->name = $name;
$this->phone = $phone;
$this->email = $email;
}
}
Example instantiation:
$contact = new Contact($customer->name,
$customer->phone,
$customer->email);