Advanced PHP Regex - Parse Wordpress Post Content -
i need extract text wordpress post.here code doesn't work, guess because regex, works fine on expresso, yet doesn't work on php.
$content = get_the_content(); preg_match('\<form id="form1.*?(?=<zmfj>)\', $content, $matches); $setupform = $matches[0]; echo $setupform;
in case variable content be:
<form id="form1" method="post" action="http://google.com"><zmfj>
so extraction result should be
<form id="form1" method="post" action="http://google.com">
preg_match("/<form[^>]+>/", $content, $matches); //the [^>]+ bit matches consecutive characters not ">"
Comments
Post a Comment