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条)

报告相同问题?

悬赏问题

  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗