gpt4 book ai didi

php - 根据其值更改返回的 $_POST 值

转载 作者:可可西里 更新时间:2023-11-01 00:09:40 24 4
gpt4 key购买 nike

当我 print_r 时,它返回一个数据数组。

print_r($_POST);

我的输入字段是标准地址信息和患者 ID:

Array ( [patient_id] => this [Last] => that [First] => Ted [ADDRESS1] => dey
[DOB] => [email] => [insurance_id] => [Phone] => [State] => CA [Zip] => 91236
[Status] => 3 [select_top] => 17 )

对于状态,通常输入 1、2 或 3。

  • 1 等于铅
  • 2 等于活跃
  • 3 等于无效

如何更改 POST 值以便在输入 3 时将其返回为 Inactive 或将 2 返回为 Active?

是否可以执行一个foreach 循环并将值更改为别名或其他内容?

foreach($_POST as $key => $val){
if($key == '3') $val = Inactive;
}

如有任何帮助,我们将不胜感激。

最佳答案

您可以使用 switch statement .无需使用 foreach 循环:

switch($_POST['status']) {
case 1: $_POST['status'] = 'Lead'; break;
case 2: $_POST['status'] = 'Active'; break;
case 3: $_POST['status'] = 'Inactive'; break;
default: $_POST['status'] = 'Huh?';
}

关于php - 根据其值更改返回的 $_POST 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16181518/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com