php - 使用 PHP 和 Regex 提取 Paypal 按钮 ID

标签 php html paypal

我有以下 Paypal“添加到购物车”HTML 按钮代码:

<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="DJ445KDUWP402">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_cart_LG.gif" border="0"   name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

使用 PHP 和正则表达式,谁能告诉我如何只获取“hosted_button_id”输入的值部分?

谢谢!

最佳答案

preg_match('~<input type="hidden" name="hosted_button_id" value="([0-9-A-Z]*?)">~', $html, $matches)
$matches[1]; //contains ID

应该可以解决问题

关于php - 使用 PHP 和 Regex 提取 Paypal 按钮 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5118952/

相关文章:

html - Angular2 设置高度为全屏

api - C# PayPal API 获取余额

html - 响应式菜单在移动设备中始终可见

paypal - 阻止通过电子支票进行 PayPal 付款

android - 与 Android 的 Paypal 集成

php - php mysql中如何连接两个表有一个将受到限制

php - 在 Laravel 的 Homestead 中运行 PHPUnit

php - APNS + PHP "stream_socket_client(): Failed to enable crypto"

php - WordPress 菜单帖子特色图片

html - 对匿名用户隐藏一些 html block