PHP | Get input name through $_POST[]

前端 未结 8 1569
长发绾君心
长发绾君心 2020-12-16 19:10

HTML example:

  
8条回答
  •  清歌不尽
    2020-12-16 19:59

    Actually I found something that might work for you, have a look at this-

    http://php.net/manual/en/function.key.php

    This page says that the code below,

     'apple',
        'fruit2' => 'orange',
        'fruit3' => 'grape',
        'fruit4' => 'apple',
        'fruit5' => 'apple');
    
    // this cycle echoes all associative array
    // key where value equals "apple"
    while ($fruit_name = current($array)) {
        if ($fruit_name == 'apple') {
            echo key($array).'
    '; } next($array); } ?>

    would give you the output,

    fruit1
    fruit4
    fruit5

    As simple as that.

提交回复
热议问题