简体   繁体   中英

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:

<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. Only the name/value pair is passed. If you want other information, you will have to pass it explicitly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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