Requested by HTML ;PPHP Code:
<?php
function GetAllStringsBetween ( $String , $Start , $End )
{
$Return = Array ( );
$Result = 0;
$LResult = 0;
while ( ( $Result = GetOffsetBetween ( $String , $Start , $End , $Result ) ) != -1 )
{
$Return[] = GetOffsetBetween ( $String , $Start , $End , $LResult );
$LResult = $Result;
}
return $Return;
}
function GetStringBetween ( $String , $Start , $End , $Offset = 0 )
{
if ( $Offset < strlen ( $String ) )
{
$StartPos = strpos ( $String , $Start , $Offset );
if ( $StartPos > -1 )
{
$EndPos = ( strpos ( $String , $End , ( $StartPos + 1 ) ) - 1 );
if ( $EndPos > -1 )
{
return substr ( $String , ( $StartPos + 1 ) , ( $EndPos - $StartPos ) );
}
}
}
return null;
}
function GetOffsetBetween ( $String , $Start , $End , $Offset = 0 )
{
if ( $Offset < strlen ( $String ) )
{
$StartPos = strpos ( $String , $Start , $Offset );
if ( $StartPos > -1 )
{
$EndPos = ( strpos ( $String , $End , ( $StartPos + 1 ) ) - 1 );
if ( $EndPos > -1 )
{
return $EndPos;
}
}
}
return -1;
}
?>
Results 1 to 2 of 2
- 24 Dec. 2010 08:47am #1
- Age
- 30
- Join Date
- Nov. 2009
- Location
- Anaheim, California
- Posts
- 1,065
- Reputation
- 99
- LCash
- 10.00
[Release - PHP] Streamlined GetStringBetween and GetAllStringBetween
- 24 Dec. 2010 08:50am #2
I.
Needed.
This.
Thanks