<?php
$txt = '<div id="central">
<p>O Primeiro conteudo</p>
<h1>O Primeiro n sei oq</h1>
<p>Batatinha quando nasce</p>
<p>Cabooo</p>
</div>';
$arr = get_tag($txt, "p");
echo $arr[1];
function get_tag($txt,$tag){
$offset = 0;
$start_tag = "<".$tag;
$end_tag = "</".$tag.">";
do{
$pos = strpos($txt,$start_tag,$offset); if($pos){
$str_pos = strpos($txt,">",$pos)+1; $end_pos = strpos($txt,$end_tag,$str_pos); $len = $end_pos - $str_pos;
$f_text = substr($txt,$str_pos,$len); $arr[] = $f_text;
$offset = $end_pos;
}
}while($pos);
return $arr;
}
PD9waHAKCiR0eHQgPSAnPGRpdiBpZD0iY2VudHJhbCI+CjxwPk8gUHJpbWVpcm8gY29udGV1ZG88L3A+CjxoMT5PIFByaW1laXJvIG4gc2VpIG9xPC9oMT4KPHA+QmF0YXRpbmhhIHF1YW5kbyBuYXNjZTwvcD4KPHA+Q2Fib29vPC9wPgo8L2Rpdj4nOwokYXJyID0gZ2V0X3RhZygkdHh0LCAicCIpOwoKZWNobyAkYXJyWzFdOyAKCmZ1bmN0aW9uIGdldF90YWcoJHR4dCwkdGFnKXsKCSRvZmZzZXQgPSAwOwoJJHN0YXJ0X3RhZyA9ICI8Ii4kdGFnOwoJJGVuZF90YWcgPSAiPC8iLiR0YWcuIj4iOwoJJGFyciA9IGFycmF5KCk7Cglkb3sKCQkkcG9zID0gc3RycG9zKCR0eHQsJHN0YXJ0X3RhZywkb2Zmc2V0KTsJCgkJaWYoJHBvcyl7CgkJCSRzdHJfcG9zID0gc3RycG9zKCR0eHQsIj4iLCRwb3MpKzE7CgkJCSRlbmRfcG9zID0gc3RycG9zKCR0eHQsJGVuZF90YWcsJHN0cl9wb3MpOwkKCQkJJGxlbiA9ICRlbmRfcG9zIC0gJHN0cl9wb3M7CgkJCSRmX3RleHQgPSBzdWJzdHIoJHR4dCwkc3RyX3BvcywkbGVuKTsKCQkJJGFycltdID0gJGZfdGV4dDsKCQkJJG9mZnNldCA9ICRlbmRfcG9zOwoJCX0KCX13aGlsZSgkcG9zKTsKCXJldHVybiAkYXJyOwp9