<?php

mb_internal_encoding("UTF-8");

class Question
{
    public $text; // текст вопроса
    public $points = 5; // число баллов, по умолчанию 5
    public $answers; // варианты ответов
    public $correctAnswer; // правильный ответ
}
$text          = "Какая планета располагается четвертой по счету от Солнца?";
$points        = 10;
$answers       = array(
    'a' => 'Венера',
    'b' => 'Марс',
    'c' => 'Юпитер',
    'd' => 'Меркурий'
);
$correctAnswer = 'b';


function createQuestions($text, $points, $answers, $correctAnswer)
{
   
    $q                = new Question;
    $q->text          = $text;
    $q->points        = $points;
    $q->answers       = $answers;
    $q->correctAnswer = $correctAnswer;
    $questions[]      = $q;
    return $q;
    
}
function printQuestions($questions)
{
    $i = 1; // номер вопроса
    
    foreach ($questions as $question) {
        echo "{$i}. {$question->text}\n\n";
        
        echo "Варианты ответов:\n";
        
        foreach ($question->answers as $letter => $answer) {
            echo "  {$letter}. {$answer}\n";
        }
        
        $i++;
    }
} {
    
}
$questions = array();
$questions[] = createQuestions($text, $points, $answers, $correctAnswer);
var_dump($questions);

$text2          = 'Какой город является столицей Великобритании?';
$points2        = 6;
$answers2       = array(
    'a' => 'Париж',
    'b' => 'Москва',
    'c' => 'Нью-Йорк',
    'd' => 'Лондон'
);
$correctAnswer2 = 'd';
$questions[]     = createQuestions($text2, $points2, $answers2, $correctAnswer2);
var_dump($questions);
printQuestions($questions);
