使用PHP时,我必须以如下格式解析代码中的字符串:
object(stdClass)(4) {
["Title"]=> string(5) "Fruit"
["Color"]=> string(6) "yellow"
["Name"]=> string(6) "banana"
["id"]=> int(3)
}
我相信有一个简单的解决方案,但我似乎找不到它...如何获取颜色和名称?
非常感谢。
发布于 2011-10-31 23:51:36
你可以这样做:$obj->Title
等。
或者,您可以将其转换为数组:
$array = get_object_vars($obj);
https://stackoverflow.com/questions/7956060
复制相似问题