WordPress – Hot to store sql output to array in PHP?
Here is function: protected function get_answers_with_question_id($id){ global $wpdb; $sql = "SELECT * FROM {$wpdb->prefix}aysquiz_answers WHERE question_id=" . $id; $answer = $wpdb->get_results($sql, 'ARRAY_A'); return $answer; } Call function: foreach ($questions_ids as $id) { $answers2[] = $this->get_answers_with_question_id2($id); } Actual output: [[{"answer":"1000"}],[{"answer":"1000"}],[{"answer":"1000"}]] I…