如何在PHP中更改HTML标记的值

时间:2022-10-27 10:59:46

I am making an email form, but I want to convert the value (I have it in numbers to calculate price) in an html tag to a word or phrase in PHP.

我正在制作一个电子邮件表单,但我希望将html标记中的值(我将其数字计算价格)转换为PHP中的单词或短语。

Toppings:
<input type="checkbox" name="ch" value="0">Cheese +$0</input>
<input type="checkbox" name="ba" value="4">Bacon +$4</input>
<input type="checkbox" name="ha" value="5">Ham +$5</input>
<input type="checkbox" name="to" value="1">Tomato +$1</input>

  $all=
"email: ".$email."\r\
".
"subject: ".$subject."\r\
".
"referer: ".$name."\r\
".
"message: ".$address."\r\
".
"phone: ".$lg." ".$md." ".$sm."\r\
".
"phone: ".$cheese." ".$bacon." ".$ham." ".$tomato."\r\
".
"phone: ".$phone."\r\
";

This will send me an email with the value. I want it to send an email with the name or whatever.

这将向我发送一封包含该值的电子邮件。我希望它发送一个带有名称或其他内容的电子邮件。

Thanks!

1 个解决方案

#1


Can't you just change the value to "0-cheese" or "4-bacon"? That way both the numbers and the word/phrase you want is included in the email.

难道你不能把价值改为“0-cheese”或“4-bacon”?这样,您想要的数字和单词/短语都包含在电子邮件中。

If you want the script to only isolate the numbers, you can use a preg_match_all function like so:

如果您希望脚本只隔离数字,可以使用preg_match_all函数,如下所示:

$str = 'In My Cart : 6 items';
preg_match_all('!\d+!', $str, $matches);

Where $str is the value of the input selected.

其中$ str是所选输入的值。

#1


Can't you just change the value to "0-cheese" or "4-bacon"? That way both the numbers and the word/phrase you want is included in the email.

难道你不能把价值改为“0-cheese”或“4-bacon”?这样,您想要的数字和单词/短语都包含在电子邮件中。

If you want the script to only isolate the numbers, you can use a preg_match_all function like so:

如果您希望脚本只隔离数字,可以使用preg_match_all函数,如下所示:

$str = 'In My Cart : 6 items';
preg_match_all('!\d+!', $str, $matches);

Where $str is the value of the input selected.

其中$ str是所选输入的值。