Severity: 8192
Message: Methods with the same name as their class will not be constructors in a future version of PHP; Cacheall_info has a deprecated constructor
Filename: libraries/cacheall_info.php
Line Number: 136
<?php
function regex_get_string_between($string, $start, $end)
{
$pattern = "/" . preg_quote($start, "/") . "(.*?)" . preg_quote($end, "/") . "/i";
preg_match($pattern, $string, $matches);
if ( ! empty($matches[1]))
return $matches[1];
return false;
}
?>
<?php
function array_get_string_between($string,$start,$end)
{
$r = explode($start, $string, 2);
if (isset($r[1]))
{
$a = explode($end, $r[1], 2);
if ($a[0] !== $r[1]) // if $end is not in $string, $a[0] will be equal to $r[1]
return $a[0];
}
return false;
}
?>
<?php
// DO NOT USE THIS FUNCTION
function get_string_between($string, $start, $end)
{
1 $string = " " . $string;
2 $ini = strpos($string, $start);
3 if ($ini == 0)
4 return false;
5
6 $ini += strlen($start);
7 $len = strpos($string, $end, $ini) - $ini;
8 return substr($string, $ini, $len);
}
?>
<?php
// DO NOT USE THIS FUNCTION
function better_get_string_between($string, $start, $end)
{
$pos = strpos($string, $start, 0);
if ($pos === false) // avoid concatenation
return false;
$pos += strlen($start);
return substr($string, $pos, strpos($string, $end, $pos) - $pos); // no assignment
}
?>
<?php
$string = "I do have start but not the other one";
$start = "start";
$end = "end";
?>
$len = strpos($string,$end,$ini) - $ini;
$len = false - 16;
substr($string,16,-16);
substr($string,34,-34);
<?php
function final_get_string_between($string, $start, $end)
{
if ( false === $pos = strpos($string, $start, 0) )
return false; // start is not found
$pos += strlen($start);
if ( false == $endpos = strpos($string, $end, $pos) )
return false; // $end is not found or $endpos is equal to $pos
return substr($string, $pos, $endpos - $pos);
}
?>
<?php
function insensitive_get_string_between($string, $start, $end)
{
if ( false === $pos = stripos($string, $start, 0) )
return false;
$pos += strlen($start);
if ( false === $endpos = stripos($string, $end, $pos) )
return false;
return substr($string, $pos, $endpos - $pos);
}
?>
<?php
// DO NOT USE THIS FUNCTION
function nocheck_get_string_between($string, $start, $end)
{
$pos = strpos($string, $start, 0) + strlen($start);
return substr($string, $pos, strpos($string, $end, $pos) - $pos);
}
?>
<?php
function one_character_get_string_between($string,$start,$end)
{
return trim(strstr(strstr($string, $start), $end, true), $start . $end);
}
?>
<?php
function array_delimiter_get_string_between($string, $delim){
$string = explode($delim, $string, 3);
return isset($string[1]) ? $string[1] : false;
}
?>
seconds name paragraph 0.470390081405640 string case insensitive (5) 0.053134918212891 regex (1) 0.047200202941895 array (2) 0.030622005462646 internet string method buggy (3) 0.029839992523193 final string with checks on start and end (4) 0.028485774993896 no checks string method buggy (6) 0.027677059173584 string with two 1 character delimiters (7) 0.023669004440308 array single delimiter $end=$start (8)
- | Function calls | Language constr. | arithmetic op. | assignments | logical checks | concatenations |
array | 3 | 1 | 0 | 2 | 2 | 0 |
internet | 4 | 0 | 2 | 2 | 1 | 1 |
final | 4 | 0 | 2 | 2 | 2 | 0 |
no checks | 4 | 0 | 2 | 1 | 0 | 0 |
1 character | 3 | 0 | 0 | 0 | 0 | 1 |
1 delimiter | 1 | 1 | 0 | 1 | 1 | 0 |
<?php
function greedy_get_string_between($string, $start, $end)
{
$pos = strpos($string, $start, 0);
if( $pos === false || strpos($string, $end, $pos) === false)
return false;
$pos += strlen($start);
return substr($string, $pos, strrpos($string,$end,$pos) - $pos);
}
/* this combines the functions selecting the best method depending on the start and end */
function get_between($string,$start,$end,$insensitive=false)
{
if (empty($string) || empty($start) ||empty($end) )
return false;
if ($start === $end)
{
$string = explode($start, $string, 3);
return isset($string[1]) ? $string[1] : false;
}
else if (strlen($start)===1 && strlen($end)===1)
{
return trim(strstr(strstr($string, $start), $end, true), $start . $end);
}
else if ( ! $insensitive)
{
if ( false === $pos = strpos($string, $start, 0) )
return false; // start is not found
$pos += strlen($start);
if ( false == $endpos = strpos($string, $end, $pos) )
return false; // $end is not found or $endpos is equal to $pos
return substr($string, $pos, $endpos - $pos);
}
else
{
if ( false === $pos = stripos($string, $start, 0) )
return false;
$pos += strlen($start);
if ( false === $endpos = stripos($string, $end, $pos) )
return false;
return substr($string, $pos, $endpos - $pos);
}
}
?>