PHP using preg_replace to remove form tags and everything in between

Using PHP I want to remove a form from a string that contains html - Here is the php code I have been trying to use but it doesn't work. Any ideas?
$html = "<form ... </form>"

$pattern = "/<form(.*?)<\/form>/i";
$html = preg_replace($pattern,"",$html);

Open in new window

dnotestineAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

codefluxCommented:
You're missing a semicolon.

<?php
$html = "before <form blah blah blah </form> after";
$pattern = "/<form(.*?)<\/form>/i";
$html = preg_replace($pattern,"",$html);
print "$html\n";
?>

Open in new window

0
codefluxCommented:
(semicolon on the first line, btw - the one declaring $html)
0
dnotestineAuthor Commented:
Thanks - the semicolon I forgot but was just for the comment here. The actual code in $html is:

<form action="http://www.artechchurchinteriors.com/portfolio/portfolio_zip_email.php" method='POST' name='hidden_email_form'>
<input type='text' id='email' name='email' value='enter email address to email list' size='35' onClick="SelectAll('email');" />&nbsp;&nbsp;
<input type='hidden' name='hidden_html' id='hidden_html' value='' />
<input type='submit' name='submit' value=' Email Now ' />
</form>

-----------------

$html = preg_replace($pattern,"",$html);
print "$html\n";

Does not take out the Form :-(
0
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

dnotestineAuthor Commented:
$pattern = "/<form(.*?)<\/form>/i";
$html = preg_replace($pattern,"",$html);
0
Terry WoodsIT GuruCommented:
This should do it:

$pattern = "/<form(.*?)<\/form>/is";
$html = preg_replace($pattern,"",$html);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Terry WoodsIT GuruCommented:
The "s" pattern modifier allows the . wildcard to match newlines
0
Terry WoodsIT GuruCommented:
Note that the round brackets are unnecessary too...

$pattern = "/<form.*?<\/form>/is";
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.