douzhong8856 2015-04-27 11:56
浏览 578
已采纳

如何在php中修改$ _post数据?

I am new to php programming language.So basically I am creating a simple form.

<?php

print_r($_POST);

?>
<form name="form1" method="post" action="">
Name: <input type="text" name="mail"><br>
Phone No: <input type="text" name="phon" /><br/>
Course:<input type="text" name="course" /> <br />
Experience: <select name="exp"> <option value="beginner">Beginner</option> <option value="intermediate">Intermediate</option> <option value="advanced">Advanced</option> </select><br>
<input type="submit" name="Submit" value="Sign Up">
</form>

So the output will be something like this:

Array ( [mail] => john [phon] => 123455666 [course] => bsc [exp] => beginner [Submit] => Sign Up )

I want to modify or change the output something like this,

Name=john Phone No=123455666 Course=bsc Experience=beginner

And I want to store that in the arrays, i.e. right hand side parameters in one array and left hand side parameters in another array. So that it will be easy to access or search the data. In the next level of this i want to save these values in a file.

Please help me out.

Any help or advice is appreciated. Thanks in advance.

</div>
  • 写回答

5条回答 默认 最新

  • dongyuan7981 2015-04-27 12:39
    关注
        $array1= array();
        $array2= array();
        foreach($_POST as $key => $value){
        echo $key ."=". $value ;
        echo "<br>";
        $array1[]=$key; //first array for left hand side 
        $array2[]=$value; //second array for right hand side
    
        }
         print_r($array1);  print_r($array2);
    
         Output:-
        phon=123456
        course=maths
        exp=intermediate
        Submit=Sign Up
    Array ( [0] => mail [1] => phon [2] => course [3] => exp [4] => Submit ) Array ( [0] => tet [1] => test [2] => stedt [3] => intermediate [4] => Sign Up )
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 鼠标右键,撤销删除 复制 移动,要怎样删除
  • ¥15 使用MATLAB进行余弦相似度计算加速
  • ¥15 服务器安装php5.6版本
  • ¥15 我想用51单片机和数码管做一个从0开始的计数表 我写了一串代码 但是放到单片机里面数码管只闪烁一下然后熄灭
  • ¥20 系统工程中,状态空间模型中状态方程的应用。请猛男来完整讲一下下面所有问题
  • ¥15 我想在WPF的Model Code中获取ViewModel Code中的一个参数
  • ¥15 arcgis处理土地利用道路 建筑 林地分类
  • ¥20 使用visual studio 工具用C++语音,调用openslsx库读取excel文件的sheet问题
  • ¥100 寻会做云闪付tn转h5支付链接的技术
  • ¥15 DockerSwarm跨节点无法访问问题