多数组形式获胜';t存储变量


multi array form won't store variables

我有一个提交给update.php的表单,它应该接受POST变量并将它们存储在另一个文件中

形式:

<fieldset>
        <legend>Proficiencies:</legend>
        <span>Name:</span> <span>exp:</span> <span>Rank:</span><br/>
        <?php
             $x = 0;
             if ($proficiencies) {
                foreach ($proficiencies as $proficiency) {
                        echo '<input type="text" name="proficiencies['.$x.'][''name'']" value="'.$proficiency["name"].'"/>';
                        echo ' <input type="text" name="proficiencies['.$x.'][''exp'']" value="'.$proficiency["exp"].'"/>';
                        echo ' <input type="text" name="proficiencies['.$x.'][''rank'']" value="'.$proficiency["rank"].'"/>';
                        echo '<br/>';
                        $x++;
               }
            }
           echo '<input type="text" name="proficiencies['.$x.'][''name'']"/>';
           echo ' <input type="text" name="proficiencies['.$x.'][''exp'']"/>';
           echo ' <input type="text" name="proficiencies['.$x.'][''rank'']"/>';
       ?>
</fieldset>

update.php:

<?php
echo 'making changes';
$user = fopen('sheets/'.$_COOKIE['username'].'.php', 'w+');
fwrite ($user, '<?php
$proficiencies = array(
');
foreach ($_POST['proficiencies'] as $proficiency) {
    if ($proficiency["name"]) {
        fwrite ($user, '    array(
        "name" => "'.$proficiency["name"].'",
        "exp" => "'.$proficiency["exp"].'",
        "rank" => "'.$proficiency["rank"].'",
    ),
'
        );
    }
}
fwrite ($user, ');
?>');
fclose($user);
?>

我已经尝试了很多不同的方法,但它就是不起作用

在html表单名称中,不允许使用引号

更改

echo '<input type="text" name="proficiencies['.$x.'][''name'']" value="'.$proficiency["name"].'"/>';
echo ' <input type="text" name="proficiencies['.$x.'][''exp'']" value="'.$proficiency["exp"].'"/>';
echo ' <input type="text" name="proficiencies['.$x.'][''rank'']" value="'.$proficiency["rank"].'"/>';

收件人:

echo '<input type="text" name="proficiencies['.$x.'][name]" value="'.$proficiency["name"].'"/>';
echo ' <input type="text" name="proficiencies['.$x.'][exp]" value="'.$proficiency["exp"].'"/>';
echo ' <input type="text" name="proficiencies['.$x.'][rank]" value="'.$proficiency["rank"].'"/>';

应该很好