HTML Get Between function PHP script
I'm wondering whether there is a php Code that help me to get some piece of text between two HTML tag or some kind of delimeter.
For Example
$string = "foo this is template text bar";
Get Template inner text like:
$innerStr = strGetBetween($string,"foo","bar");
It returns: " this is template text ". finally, this code i found much helpful in this situation to get text Between Strings, tags and delimeters.
*PHP Code Snippet*
<?php function strGetBetween($content,$start,$end){ $r = explode($start, $content); if (isset($r[1])){ $r = explode($end, $r[1]); return $r[0]; } return ''; } ?>Example To Get Results:
<?php $data = "foo this is template text bar" $start = "foo "; $end = " baar "; $results = strGetBetween($data,$start,$end); echo $results; ?>i hope this will helps you alot, Please share this article with your friends.
0 Response to "HTML Get Between function PHP script "
Post a Comment
Note: only a member of this blog may post a comment.