for example: I want to get a specific text from this text after the word investor and before the word harga
abstrak investor evaluasi analisis faktor mempengaruhi nilai intrinsik harga saham
so the result would be
evaluasi analisis faktor mempengaruhi nilai intrinsik
but in the other case, I also have string, and I want to get a text after the word tersedia and before the word timbul
informasi tersedia investor evaluasi analisis faktor mempengaruhi kondisi perusahaan dimasa investor memperkecil kerugian timbul seminimal fluktuasi pertumbuhan perkembangan perusahaan
so the result would be
investor evaluasi analisis faktor mempengaruhi kondisi perusahaan dimasa investor memperkecil kerugian
I've use this code, to get a text after and before a certain word, but it only has two fixed parameter, the "start word" and the "end word". Is it possible to make it more dynamic or on the other word add rule/more than two parameters?
<?php
function get_string_between($string, $start, $end){
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}
$fullstring = "this is my [tag]dog[/tag]";
$parsed = get_string_between($fullstring, "[tag]", "[/tag]");
echo $parsed; // (result = dog)
?>
Any helps would be appreciated. Thank you.