Voting

: six minus two?
(Example: nine)

The Note You're Voting On

mr davin
17 years ago
<?php
// Returns an array of strings where the start and end are found
function findinside($start, $end, $string) {
preg_match_all('/' . preg_quote($start, '/') . '([^\.)]+)'. preg_quote($end, '/').'/i', $string, $m);
return
$m[1];
}

$start = "mary has";
$end = "lambs.";
$string = "mary has 6 lambs. phil has 13 lambs. mary stole phil's lambs. now mary has all the lambs.";

$out = findinside($start, $end, $string);

print_r ($out);

/* Results in
(
[0] => 6
[1] => all the
)
*/
?>

<< Back to user notes page

To Top