简体   繁体   English

如何在foreach中从$ key中获取标签,占位符或id而不是名称($ _POST as $ key => $ value){

[英]How do I get label, placeholder or id instead of name from $key in foreach($_POST as $key=>$value){

I have dynamic field names that are being posted to my mail processor. 我有动态字段名称,这些名称正在发布到我的邮件处理器中。 I need to get the label, placeholder or id instead of the name from the following form: 我需要从以下形式获取标签,占位符或ID而不是名称:

<label for='name' >Nombre</label>
<input type='text' class="form-control" name='name' id='Nombre' value='<?php echo $formproc->SafeDisplay('name') ?>' placeholder="Nombre" />

This is the code: 这是代码:

$ret_str='';
        foreach($_POST as $key=>$value)
        {
            if(!$this->IsInternalVariable($key))
            {
                $value = htmlentities($value,ENT_QUOTES,"UTF-8");
                $value = nl2br($value);
                $key = ucfirst($key);
                $ret_str .= "<p>$key: $value\n</p>";
            }
        }
return $ret_str;

But this is the result: 但这是结果:

Name: Example

That information isn't passed via POST. 该信息不会通过POST传递。 Only the name/value pair is passed. 仅传递名称/值对。 If you want other information, you will have to pass it explicitly. 如果您需要其他信息,则必须显式传递它。

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

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