Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Deekshith's avatar

fetach wpProquiz wordpress plugin question and answer in laravel

i have wordpress site and also i am working on api in laravel and communicating with wordpress DB. i am using corcel package to fetch data and all. now in wordpress i have quiz plugin (wpproquiz). to fetch the questions i am passing the quiz id using below query,

preg_match('/\[WpProQuiz\s(.*?)\]/', $postdetail->post_content, $matches);
  $quizids = $matches[1];

  $getquestions = DB::connection('connectionname')->table('wp_pro_quiz_question')->where('quiz_id',$quizids)->get();

And all other fields are working fine. when i checked the answer_data column i found that all options are serialized and when i used below code to display unserialized data ,

 $answers = unserialize($que->answer_data);
 dd($answers);

Response is,

array:4 [▼
  0 => __PHP_Incomplete_Class(WpProQuiz_Model_AnswerTypes) {#1467 ▼
    #_answer: "a) Australia"
    #_html: false
    #_points: 1
    #_correct: false
    #_sortString: ""
    #_sortStringHtml: false
    #_mapper: null
  }
  1 => __PHP_Incomplete_Class(WpProQuiz_Model_AnswerTypes) {#1469 ▶}
  2 => __PHP_Incomplete_Class(WpProQuiz_Model_AnswerTypes) {#1480 ▶}
  3 => __PHP_Incomplete_Class(WpProQuiz_Model_AnswerTypes) {#1479 ▶}
]

But here i am not able to fetch the fields as key name showing the function. how to fetch these data using foreach?

0 likes
0 replies

Please or to participate in this conversation.