mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-10 00:54:27 +02:00
Merge pull request #4399 from MrPetovan/task/3878-move-include-bbcode-to-src
Move include/bbcode to src/ part 1 : Everything but bbcode()
This commit is contained in:
commit
85c8bf0228
15 changed files with 1615 additions and 1505 deletions
File diff suppressed because it is too large
Load diff
|
@ -34,4 +34,41 @@ class Plaintext
|
|||
|
||||
return $msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the character positions of the provided boundaries, optionally skipping a number of first occurrences
|
||||
*
|
||||
* @param string $text Text to search
|
||||
* @param string $open Left boundary
|
||||
* @param string $close Right boundary
|
||||
* @param int $occurrences Number of first occurrences to skip
|
||||
* @return boolean|array
|
||||
*/
|
||||
public static function getBoundariesPosition($text, $open, $close, $occurrences = 0)
|
||||
{
|
||||
if ($occurrences < 0) {
|
||||
$occurrences = 0;
|
||||
}
|
||||
|
||||
$start_pos = -1;
|
||||
for ($i = 0; $i <= $occurrences; $i++) {
|
||||
if ($start_pos !== false) {
|
||||
$start_pos = strpos($text, $open, $start_pos + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if ($start_pos === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$end_pos = strpos($text, $close, $start_pos);
|
||||
|
||||
if ($end_pos === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$res = ['start' => $start_pos, 'end' => $end_pos];
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue