I am pulling data from a file that I have cleaned up with preg_replace
.
Problem is it's only returning the $output
once even though there is multiple $content
through out the document.
I need to use a loop however I have no clue how to get it to work. I have tried to use this code from this link but can't get it to work properly in terms of echo $output
.
Here is my code :
<?php
$getme = file_get_contents("somefile.txt");
$string = preg_replace('/[^A-Za-z\-]/', '', $getme);
function get_between($content,$start,$end){
$r = explode($start, $content);
if (isset($r[1])){
$r = explode($end, $r[1]);
return $r[0];
}
return '';
}
$content = $string;
$start = "somestuff";
$end = "morestuff";
$output = get_between($content,$start,$end);
echo $output;
?>
Any help would be appreciated.