X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=c30908e2d48a18c3eebf31790fd9330ff08d5a28;hb=db09724aec91a55ba76d8e0cd451a91895bc1e9c;hp=6f22d1970257ac9d0f9d4700640c3f3cb4180aa9;hpb=9ae5ae6df53ffda18008304435dffbde379516f2;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index 6f22d19702..c30908e2d4 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -47,6 +47,30 @@ function bb_unspacefy_and_trim($st) { return $unspacefied; } +function bb_find_open_close($s, $open, $close, $occurance = 1) { + + if($occurance < 1) + $occurance = 1; + + $start_pos = -1; + for($i = 1; $i <= $occurance; $i++) { + if( $start_pos !== false) + $start_pos = strpos($s, $open, $start_pos + 1); + } + + if( $start_pos === false) + return false; + + $end_pos = strpos($s, $close, $start_pos); + + if( $end_pos === false) + return false; + + $res = array( 'start' => $start_pos, 'end' => $end_pos ); + + return $res; +} + function get_bb_tag_pos($s, $name, $occurance = 1) { if($occurance < 1)