1

我有这样的html元素:

<div id="show">
<p>1. <input name="name[]" size="25" type="text">
<input name="surname[]" size="25" type="text">
<input name="email[]" size="50" type="text"></p>

<p>2. <input name="name[]" size="25" type="text">
<input name="surname[]" size="25" type="text">
<input name="email[]" size="50" type="text"></p>

<p>3. <input name="name[]" size="25" type="text">
<input name="surname[]" size="25" type="text">
<input name="email[]" size="50" type="text"></p>

<p>4. <input name="name[]" size="25" type="text">
<input name="surname[]" size="25" type="text">
<input name="email[]" size="50" type="text"></p>

<p>5. <input name="name[]" size="25" type="text">
<input name="surname[]" size="25" type="text">
<input name="email[]" size="50" type="text"></p>
</div>

这是带有虚拟数据的输出屏幕。在此处输入图像描述 当我序列化 div#show 并发布它时,转储数据如下所示:

array (size=3)
  0 => 
    array (size=5)
      0 => string 'Hüsamettin' (length=11)
      1 => string 'Niyazi' (length=6)
      2 => string 'Abuzittin' (length=9)
      3 => string 'Haşmet' (length=7)
      4 => string 'Birben' (length=6)
  1 => 
    array (size=5)
      0 => string 'Karadayürümez' (length=15)
      1 => string 'Tuzyemez' (length=8)
      2 => string 'Yerebasmaz' (length=10)
      3 => string 'Haşmetligil' (length=12)
      4 => string 'Eksiktim' (length=8)
  2 => 
    array (size=5)
      0 => string 'husamettin@getmail.us' (length=21)
      1 => string 'tuzyemez@postmail.us' (length=20)
      2 => string 'abuzittin@setmail.us' (length=20)
      3 => string 'hasmetligil@mail.us' (length=19)
      4 => string 'birseneksiktim@mail.us' (length=22)

你看,第一个数组收集姓名,第二个数组收集姓氏,第三个数组收集电子邮件地址。但我想像这样收集它们:

array (size=5)
  0 => 
    array (size=3)
      0 => string 'Hüsamettin' (length=11)
      1 => string 'Karadayürümez' (length=15)
      2 => string 'husamettin@getmail.us' (length=21)
  1 => 
    array (size=3)
      0 => string 'Niyazi' (length=6)
      1 => string 'Tuzyemez' (length=8)
      2 => string 'tuzyemez@postmail.us' (length=20)
  2 => 
    array (size=3)
      0 => string 'Abuzittin' (length=9)
      1 => string 'Yerebasmaz' (length=10)
      2 => string 'abuzittin@setmail.us' (length=20)
  3 => 
    array (size=3)
      0 => string 'Haşmet' (length=7)
      1 => string 'Haşmetligil' (length=12)
      2 => string 'hasmetligil@mail.us' (length=19)
  4 => 
    array (size=3)
      0 => string 'Birben' (length=6)
      1 => string 'Eksiktim' (length=8)
      2 => string 'birseneksiktim@mail.us' (length=22)

此数组类型收集人的姓名、姓氏和电子邮件地址,如上图所示。请你帮我,我如何创建一个从第一个 HTML 元素中收集某人的姓名、姓氏和电子邮件地址的数组?亲切的问候。

4

1 回答 1

4
$grouped = array_map(null, $_POST['name'], $_POST['surname'], $_POST['email']);
于 2013-04-13T15:25:22.793 回答