search

Home  >  Q&A  >  body text

$fields = $values ​​= [];This code cannot be defined and keeps reporting errors. The teacher’s source code also reports errors and cannot be executed. How can I solve this problem?

老师代码截图.PNG实践结果.PNG我的代码截图.PNG

手机用户1599665486手机用户15996654861510 days ago1082

reply all(3)I'll reply

  • 执笔画卿颜 丶

    执笔画卿颜 丶2020-10-14 01:07:58

    if ($type == 'insert') {
        $fields = $values = [];
        foreach ($data as $key => $value) {
            // 键值存入$fields
            $fields[] = $key;
            // 值存入$values;
            $values[] = $value;
        }
    }

    reply
    0
  • 二娃你先上

    二娃你先上2020-10-12 11:38:24

    The foreach you wrote is $key=>$value, and $val is used for assignment below. This is definitely wrong.

    reply
    0
  • 零时差

    Uh uh uh

    零时差 · 2020-10-12 16:32:53
  • Cancelreply