English 中文(简体)
在php 中将特定变量从数组中拉出 [关闭]
原标题:pulling a specific variable out of an array in php [closed]
Closed. This question needs to be more focused. It is not currently accepting answers.

想要改进这个问题吗? 更新问题,使其只关注一个问题

Closed 10 years ago.

这是用于产品回报的在线表格。 用户从菜单、 退款、 替换、 90 DaysExpressed 等中选择( 以下显示选择) 。 这些选择中, 每一个都有相应的信息( 在变量中, 也显示在下面 ) 。 我希望根据用户的选择, 变量( $tbrefund, $tbreplace等) 的价值被传递到变量 $sage 。

这是我至今为止拥有的东西, 我得到的错误如下:

<强度 > 通知: 未定义变量: 消息

$Rarray = array(
"Refund" => "$tbrefund",
"Replacement" => "$tbreplace",
"90DaysExpired" => "$expiredwarranty",
"ContactTech" => "$contacttech",
"RefundExpiredReplace" => "$outsiderefund",
"NoExRefund" => "$noexchange",
"ManuWarranty" => "$manuwarranty",
);

if (isset($Rarray[$Request]))
   $message =  $Rarray[$Request];

非常感谢任何帮助。

edit: this is the line producing the error, I already know it s not relevent...

$send_contact=mail($to,$subject,$message,$header);

为什么你要压低某人的选票 请求帮助?

最佳回答

错误是因为 $Request 没有正确设置 。

if (isset($Rarray[$Request]))
{
   $message = $Rarray[$Request];
}
else
{
   $message = "Invalid";
}

那么,你的实际问题是“为什么$要求不起作用?”

答案是,它取决于$要求来自何方, 所以你需要向我们展示一些 $要求回响( 或 var_ dump () ) 的例子—— 但我会冒风险猜测您正在发送$要求小写( 如果是通过 URL 或某物发送的话) —— 但您的数组已被资本化 。

编辑:我希望你不会期望你的信息是“$tbrewplace”或其它东西。

我猜你是想做这种事吧?

$Rarray = array(
"Refund" => $tbrefund,
"Replacement" => $tbreplace,
"90DaysExpired" => $expiredwarranty,
"ContactTech" => $contacttech,
"RefundExpiredReplace" => $outsiderefund,
"NoExRefund" => $noexchange,
"ManuWarranty" => $manuwarranty
);
问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签