PHP-使用regex从MailChimp订阅表单代码中提取表单操作URL [英] PHP - Extract form action url from mailchimp subscribe form code using regex

查看:23
本文介绍了PHP-使用regex从MailChimp订阅表单代码中提取表单操作URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的用户创建自定义MailChimp表单模板。

所以我想从MailChimp代码中提取ONLY表单操作URL..

谁能告诉我如何从以下代码中提取操作URL。

<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="http://xxxxxxxx.us5.list-manage.com/subscribe/post?u=xxxxxxxxxxxxxxxxxx&amp;id=xxxxxxx" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
    <h2>Subscribe to our mailing list</h2>
<div class="indicates-required"><span class="asterisk">*</span> indicates required</div>
<div class="mc-field-group">
    <label for="mce-EMAIL">Email Address  <span class="asterisk">*</span>
</label>
    <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
    <label for="mce-FNAME">First Name </label>
    <input type="text" value="" name="FNAME" class="" id="mce-FNAME">
</div>
<div class="mc-field-group">
    <label for="mce-LNAME">Last Name </label>
    <input type="text" value="" name="LNAME" class="" id="mce-LNAME">
</div>
    <div id="mce-responses" class="clear">
        <div class="response" id="mce-error-response" style="display:none"></div>
        <div class="response" id="mce-success-response" style="display:none"></div>
    </div>  <div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</form>
</div>

<!--End mc_embed_signup-->

推荐答案

preg_match('|form action="([^"]*?)" method="post" id="mc-embedded-subscribe-form"|i', $html, $matches);
$url = $matches[1];

这篇关于PHP-使用regex从MailChimp订阅表单代码中提取表单操作URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆