fork download
  1. // Функция, создающая массив с вопросами:
  2. function createQuestions()
  3. {
  4. // Создаем пустой массив
  5. $questions = [];
  6.  
  7. // Создаем и заполняем первый объект
  8. $q = new Question;
  9. $q->text = ...
  10. ...
  11. // Кладем вопрос в массив
  12. $questions[] = $q;
  13.  
  14. // Создаем второй объект
  15. $q = new Question;
  16. ...
  17.  
  18. return $questions;
  19. }
Success #stdin #stdout 0.01s 82880KB
stdin
Standard input is empty
stdout
// Функция, создающая массив с вопросами:
function createQuestions()
{
    // Создаем пустой массив
    $questions = [];

    // Создаем и заполняем первый объект
    $q = new Question;
    $q->text = ...
    ...
    // Кладем вопрос в массив
    $questions[] = $q;

    // Создаем второй объект
    $q = new Question;
    ...

    return $questions;
}