-4

我想从几种不同的格式中反序列化一个字符串。第一种格式是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?
}
4

1 回答 1

2

就这么简单:

$myObj->$member_name = $value;
于 2013-04-24T22:11:19.460 回答