简体   繁体   English

显示内联数组

[英]Display inline arrays

  var html3 = '<div class="row" id="parent-autor"> <p id="auth-del"><i class="fa fa-minus-square" aria-hidden="true"></i></p> <div class="col-md-4"> <div class="form-group"> <input type="text" class="form-control" name="altautorprenume[]" placeholder="Prename"> </div> </div> <div class="col-md-4"> <div class="form-group"> <input type="text" class="form-control" name="altautornume[]" placeholder="Name"> </div> </div><div class="col-md-4"> <div class="form-group"> <input type="text" class="form-control" name="institutie[]" id="institutie" placeholder="Institutions"> </div> </div></div>'; $("#add_aut").click(function(e){ $('#auth-rows').append(html3); }); $('#auth-rows').on('click', '#auth-del', function(E){ $(this).parent('div').remove(); }); 
 <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="row"> <div class="add-plus"></div> <div class="col-md-12"> <h5>Add more persons </h5> <span class="btn btn-primary" id="add_aut" style="">Click here to add</span> </div> </div> <div id="auth-rows"></div> 

i have an formular which user can add more clients to invite at party when user click on Add a new row with 3 fields appear he can add how many he want, these values dynamically i want to show on email, for example: 我有一个公式编辑器,当用户单击添加具有3个字段的新行时,用户可以添加更多客户邀请参加聚会,他可以添加他想要的数量,这些值是我想动态显示在电子邮件上的,例如:

User fill all fields and add 3 more users where they have Name PreName Instituional,look what i did: 用户填写所有字段,并在具有Name PreName Instituional的位置添加3个其他用户,看看我做了什么:

$personName= $_POST['personname'];
$personPrename= $_POST['personprename'];
$institution= $_POST['institution'];
$otherPersonName=" "; 
$otherPersonPreName="";
$otherPersonInstitution= "";

 foreach($personName as $product) {
  $otherPersonPreName.= "$product";
}

foreach($personPrename as $products) {
  $altiautoriNume .= "$products";
}

foreach($institution as $productss) {
  $otherPersonInstitution.= "$productss";
} 
EXAMPLE:
And in email content i want to display like this:
<hr>
John(first name of person added) Doe(first Prename of person added) Microsoft(first Institution of person added)
<hr>
Mike(second name of person added) Stuart(second Prename of person added)  Facebook(second Institution of person added)
<hr>

I know i did something wrong. 我知道我做错了。 I put even html to see truly what i want to do, i want to group Name Prename Institution per line 我什至连html都可以看到我真正想做的事情,我想每行将名称预命名机构分组

You can use array-map with null as first parameter to group the array and then use implode to concat the strings. 您可以使用null为第一个参数的array-map对数组进行分组,然后使用implode合并字符串。

Consider the following: 考虑以下:

$arr = array_map(null, $personName, $personPrename, $institution);
foreach($arr as $e)
    echo implode(" ", $e) . PHP_EOL;

Live example: 3v4l 直播示例: 3v4l

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM