html名称标签数组类型命名元素的不同方式

发布于 2025-02-05 18:29:37 字数 1830 浏览 5 评论 0原文

在一个项目中,我必须克隆我的输入元素。我在Google中搜索,并找到了不同的方法来做到这一点。一种方法是创建HTML名称标签输入数组。但是在不同地点的命名约定是不同的。就像,

<div id="content">
    <div class="row i_bike_servicing">
        <div class="col-md-2 p-2">
            <input type="text" class="form-control" name="from_place[]">
        </div>
        <div class="col-md-1 p-2">
            <input type="text" class="form-control" name="from_date[]">
        </div>
    </div>
</div>

我发现的另一种方式是:

<div id="content">
    <div class="row i_bike_servicing">
        <div class="col-md-2 p-2">
            <input type="text" class="form-control" name="bike_servicing[from_place][]">
        </div>
        <div class="col-md-1 p-2">
            <input type="text" class="form-control" name="bike_servicing[from_date][]">
        </div>
    </div>
</div>

并且也这样:

<div id="content">
    <div class="row i_bike_servicing">
        <div class="col-md-2 p-2">
            <input type="text" class="form-control" name="from_places[][from_place]">
        </div>
        <div class="col-md-1 p-2">
            <input type="text" class="form-control" name="from_dates[][from_date]">
        </div>
    </div>
</div>

这三种不同的名称标签数组语法的含义是什么?在这种情况下,我们必须选择哪个命名约定或所有这些命名是相同的?

参考: https:> https:> https: //laracasts.com/discuss/channels/general-discussion/any-better-way-way-to-to-transform-this-this-html-input-raray

In a project, I have to clone my input elements. I searched in google and found different ways to do this. One way was to create html name tag input array. But the naming convention was different in different sites. Like,

<div id="content">
    <div class="row i_bike_servicing">
        <div class="col-md-2 p-2">
            <input type="text" class="form-control" name="from_place[]">
        </div>
        <div class="col-md-1 p-2">
            <input type="text" class="form-control" name="from_date[]">
        </div>
    </div>
</div>

Another way I found was:

<div id="content">
    <div class="row i_bike_servicing">
        <div class="col-md-2 p-2">
            <input type="text" class="form-control" name="bike_servicing[from_place][]">
        </div>
        <div class="col-md-1 p-2">
            <input type="text" class="form-control" name="bike_servicing[from_date][]">
        </div>
    </div>
</div>

And also like this:

<div id="content">
    <div class="row i_bike_servicing">
        <div class="col-md-2 p-2">
            <input type="text" class="form-control" name="from_places[][from_place]">
        </div>
        <div class="col-md-1 p-2">
            <input type="text" class="form-control" name="from_dates[][from_date]">
        </div>
    </div>
</div>

What is the meaning of these three different approaches of name tag array syntax? In which case, we have to select which one naming convention or all of these are same?

Reference: https://laracasts.com/discuss/channels/general-discussion/any-better-way-to-transform-this-html-input-array

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

送君千里 2025-02-12 18:29:37
from_place[], simple array, example :

from_place[0] = 'A',
from_place[1] = 'B',
from_place[2] = 'C'
= from_place = 0 = A
               1 = B
               2 = C

bike_servicing[from_place][], you can store data with `from_place` as the first key and each of them has a unique child key, example :

bike_servicing[from_place][0] = 'A',
bike_servicing[from_place][1] = 'B',
bike_servicing[from_place][2] = 'C'
= bike_servicing = from_place = 0 = 'A'
                              = 1 = 'B'
                              = 2 = 'C'

from_places[][from_place], lets say you can store data with unique key and `from_place` is the name for each key, example :

from_places[1][place] = 'A',
from_places[2][place] = 'B',
from_places[3][place] = 'C'
= from_places = 1st place = 'A'
                2nd place = 'B'
                3rd place = 'C'

Some reference : https://www.geeksforgeeks.org/multidimensional-arrays-in- php/

from_place[], simple array, example :

from_place[0] = 'A',
from_place[1] = 'B',
from_place[2] = 'C'
= from_place = 0 = A
               1 = B
               2 = C

bike_servicing[from_place][], you can store data with `from_place` as the first key and each of them has a unique child key, example :

bike_servicing[from_place][0] = 'A',
bike_servicing[from_place][1] = 'B',
bike_servicing[from_place][2] = 'C'
= bike_servicing = from_place = 0 = 'A'
                              = 1 = 'B'
                              = 2 = 'C'

from_places[][from_place], lets say you can store data with unique key and `from_place` is the name for each key, example :

from_places[1][place] = 'A',
from_places[2][place] = 'B',
from_places[3][place] = 'C'
= from_places = 1st place = 'A'
                2nd place = 'B'
                3rd place = 'C'

Some reference : https://www.geeksforgeeks.org/multidimensional-arrays-in-php/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文