我想从几种不同的格式反序列化字符串。第一种格式是json。
$myObj = new myObject();
$unserialized = json_decode($input, true);
foreach ($unserialized as $member_name => $value){
$myObj[$member_name] = $value; // <= How do I do what this is trying to do?
}
答案 0 :(得分:2)
这很简单:
$myObj->$member_name = $value;