我面临着在数组后检索值的问题。请让我知道我是如何得到的。我想得到第一个价值' [_回答]'
WpProQuiz_Model_AnswerTypes Object
(
[_answer:protected] => new1
[_html:protected] =>
[_points:protected] => 1
[_correct:protected] =>
[_sortString:protected] =>
[_sortStringHtml:protected] =>
[_mapper:protected] =>
)
Basically i am trying to getting data from serialize data and after unserialize it is showing above output:
a:4:{i:0;O:27:"WpProQuiz_Model_AnswerTypes":7: {s:10:"*_answer";s:4:"new1";s:8:"*_html";b:0;s:10:"*_points";i:1;s:11:"*_correct";b:0;s:14:"*_sortString";s:0:"";s:18:"*_sortStringHtml";b:0;s:10:"*_mapper";N;}i:1;O:27:"WpProQuiz_Model_AnswerTypes":7:{s:10:"*_answer";s:4:"new2";s:8:"*_html";b:0;s:10:"*_points";i:1;s:11:"*_correct";b:1;s:14:"*_sortString";s:0:"";s:18:"*_sortStringHtml";b:0;s:10:"*_mapper";N;}i:2;O:27:"WpProQuiz_Model_AnswerTypes":7:{s:10:"*_answer";s:4:"new3";s:8:"*_html";b:0;s:10:"*_points";i:1;s:11:"*_correct";b:0;s:14:"*_sortString";s:0:"";s:18:"*_sortStringHtml";b:0;s:10:"*_mapper";N;}i:3;O:27:"WpProQuiz_Model_AnswerTypes":7:{s:10:"*_answer";s:4:"new4";s:8:"*_html";b:0;s:10:"*_points";i:1;s:11:"*_correct";b:0;s:14:"*_sortString";s:0:"";s:18:"*_sortStringHtml";b:0;s:10:"*_mapper";N;}}
答案 0 :(得分:0)
这是一个对象,而不是一个数组。 您有两种方法可以访问它的属性。
您可以使用echo WpProQuiz_Model_AnswerTypes->_answer
或者你把它投射到像这样的数组
$asArray = (array)WpProQuiz_Model_AnswerTypes;
echo $asArray['_answer'];