I am showing to you another PHP code snippet. Its function is to identify what string is in between 2 given offsets like the starting point and the end point of string which you wanna retrieve. Here is the code.
function strbet($input, $start, $end){
$substr = substr($input, strlen($start)+strpos($input, $start), (strlen($input) - strpos($input, $end))*(-1));
return $substr;
}
Now, lets give it a try.
Assuming the following statement:
//You have an input string which you want to process and it so happened that you need to identify what string is in between 2 points there. So,
$my_string = "websitedecoration.blogspot.com";
//And then you wll provide the 2 offset, start and end
//Start position
$start = 0;
//End position
$end = 16;
//call the strbet function
$processed_string = strbet($my_string, $start, $end);
echo $processed_strin;
//Output
websitedecoration
Have a happy coding.
No comments:
Post a Comment