PDA

View Full Version : الگوی مورد نظر برای گرفتن متن



omid_student
سه شنبه 11 اسفند 1394, 04:23 صبح
سلام دوستان
من در متن زیر میخوام الگوی تعریف بشه که داخل تگ article رو بگیرم
هر کاری کردم هم نشد
الگوی این چی میتونه باشه

<article id="post-62135" class="vce-single post-62135 post type-post status-publish format-standard has-post-thumbnail hentry category-news tag-bethesda tag-fallout-4">


<header class="entry-header">
......................
.....................
.............................
</header>

</div>
</article>

mojooriass
پنج شنبه 13 اسفند 1394, 07:06 صبح
<?php
function getTextBetweenTags($string, $tagname) {
$pattern = "/<$tagname ?.*>(.*)<\/$tagname>/";
preg_match($pattern, $string, $matches);
return $matches[1];
}


$txt = getTextBetweenTags($str, "article");
echo $txt;
?>