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

如何在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条)

报告相同问题?

悬赏问题

  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站