PHP code example of liesauer / get-middle-text
1. Go to this page and download the library: Download liesauer/get-middle-text library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
liesauer / get-middle-text example snippets
getMiddleText($text, '<body>', '</body>');
getMiddleText($text, '<title>', '</title>', 10);
getMiddleText($text, '<title>', '</title>', 10, $pos);
getMiddleText($text, '<div>', '</div>', $pos, $pos, INCLUDING_BOTH);
getMiddleText($text, '', 'html>', 0, $pos, INCLUDING_RIGHT);
getMiddleText($text, '<div>', '</div>', 0, $pos, INCLUDING_BOTH);
getMiddleText($text, '<html>', '', 0, $pos, INCLUDING_LEFT);
getMiddleTexts($text, '<title>', '</title>');
text
INCLUDING_NOTHING 不追加文本
INCLUDING_LEFT 追加左边文本
INCLUDING_RIGHT 追加右边文本
INCLUDING_BOTH 追加两边文本
text
/**
* 取中间文本
* @param string $wholeText 寻找文本
* @param string $leftText 左边文本
* @param string $rightText 右边文本
* @param int $offset 开始查找位置
* @param int &$position 返回第一个找到文本的位置,找不到返回-1
* @param int $padding 填充
* @return string|false
*/
function getMiddleText($wholeText, $leftText, $rightText, $offset = 0, &$position = 0, $padding = INCLUDING_NOTHING) {}
/**
* 取中间文本组
* @param string $wholeText 寻找文本
* @param string $leftText 左边文本
* @param string $rightText 右边文本
* @param int $offset 开始查找位置
* @param int &$position 返回最后找到文本的位置,找不到返回-1
* @param int $padding 填充
* @return string[]
*/
function getMiddleTexts($wholeText, $leftText, $rightText, $offset = 0, &$position = 0, $padding = INCLUDING_NOTHING) {}