help about text between and replace it
Posted: Sat Jan 23, 2010 8:21 am
hello
I want select text between some html code and then replace it by ''.( replace from 'href' until '">' then replace this text with '')
this is my code :
<?php
set_time_limit(0) ;
ob_implicit_flush(true);
ob_end_flush();
function TextBetween($s1,$s2,$s){
$s1 = strtolower($s1);
$s2 = strtolower($s2);
$L1 = strlen($s1);
$scheck = strtolower($s);
if($L1>0){$pos1 = strpos($scheck,$s1);} else {$pos1=0;}
if($pos1 !== false){
if($s2 == '') return substr($s,$pos1+$L1);
$pos2 = strpos(substr($scheck,$pos1+$L1),$s2);
if($pos2!==false) return substr($s,$pos1+$L1,$pos2);
}
return '';
}
$title = 'Jornal O Estado de SP em href="http://domain.com/tag/pdf/" class="st_tag internal_tag" rel="tag" title="Posts tagged with pdf">PDF, Sábado, 23 de href="http://domain.com/tag/janeiro/" class="st_tag internal_tag" rel="tag" title="Posts tagged with janeiro">Janeiro de 2010
href="http://domain.com/tag/pdf/" class="st_tag internal_tag" rel="tag" title="Posts tagged with pdf">PDF | href="http://domain.com/tag/brazil/" class="st_tag internal_tag" rel="tag" title="Posts tagged with brazil">Brazil | 84 href="http://domain.com/tag/pages/" class="st_tag internal_tag" rel="tag" title="Posts tagged with pages">Pages | 32 MB';
$title3 = textbetween('href="','">',$title);
while ($title3 != "")
{
$title2 = str_ireplace ($title3,'',$title);
echo $title2."<br>" ;
}
echo $title2."<br>" ;
?>
anyone can help me?
I want select text between some html code and then replace it by ''.( replace from 'href' until '">' then replace this text with '')
this is my code :
<?php
set_time_limit(0) ;
ob_implicit_flush(true);
ob_end_flush();
function TextBetween($s1,$s2,$s){
$s1 = strtolower($s1);
$s2 = strtolower($s2);
$L1 = strlen($s1);
$scheck = strtolower($s);
if($L1>0){$pos1 = strpos($scheck,$s1);} else {$pos1=0;}
if($pos1 !== false){
if($s2 == '') return substr($s,$pos1+$L1);
$pos2 = strpos(substr($scheck,$pos1+$L1),$s2);
if($pos2!==false) return substr($s,$pos1+$L1,$pos2);
}
return '';
}
$title = 'Jornal O Estado de SP em href="http://domain.com/tag/pdf/" class="st_tag internal_tag" rel="tag" title="Posts tagged with pdf">PDF, Sábado, 23 de href="http://domain.com/tag/janeiro/" class="st_tag internal_tag" rel="tag" title="Posts tagged with janeiro">Janeiro de 2010
href="http://domain.com/tag/pdf/" class="st_tag internal_tag" rel="tag" title="Posts tagged with pdf">PDF | href="http://domain.com/tag/brazil/" class="st_tag internal_tag" rel="tag" title="Posts tagged with brazil">Brazil | 84 href="http://domain.com/tag/pages/" class="st_tag internal_tag" rel="tag" title="Posts tagged with pages">Pages | 32 MB';
$title3 = textbetween('href="','">',$title);
while ($title3 != "")
{
$title2 = str_ireplace ($title3,'',$title);
echo $title2."<br>" ;
}
echo $title2."<br>" ;
?>
anyone can help me?