我正在尝试从预定义的数据中保存几个对象。它只保存第一组数据,或者如果我更改代码,它会将数据保存为“数组”。这是代码:
<?php
$category = array(
'Account/Profile',
'Blogs',
);
$question = array(
'How do I change my email notifications',
'How do I edit my profile details',
'What is a blog?',
);
$answer = array(
'<p>To change your email notifications</p>',
'<p>To change your profile details</p>',
'<p>A weblog, or blog, is.</p>',
);
$questionCount = count($question);
for ($i = 0; $i <= $questionCount; $i++) {
$faq = new Object();
$faq->category = $category[$i];
$faq->question = $question[$i];
$faq->answer = $answer[$i];
}
$didSave = $faq->save();
如何从数组中提取数据并使用该数据创建多个对象?