定制 todayislifedevelopment/textbetween 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

todayislifedevelopment/textbetween

Composer 安装命令:

composer require todayislifedevelopment/textbetween

包简介

Searches for text inside of nested tags

README 文档

README

textbetween

Extracts the text between two tags in a string.

  • @param string $starttag The start tag of the text to extract.
  • @param string $endtag The end tag of the text to extract.
  • @param string $string The string to be searched.
  • @param int $occurrence The number of the tag to extract from (default: 1).
  • @param bool $force Specifies whether the function should return an empty result if the end tag is not found (default: true).

  • @return string The extracted text between the tags or an empty string if $force is set to false and the end tag is not found.

Features

  • Respects nested tags

Installation

composer require todayislifedevelopment/textbetween

Usage/Examples

require_once('textbetween');

$string = "<p>First</p>Nothing<p>Second<p>Next Level</p></p>Rest";

echo textbetween('<p>', '</p>', $string) . "\n";           // "First"
echo textbetween('<p>', '</p>', $string, 1) . "\n";        // "First"
echo textbetween('<p>', '</p>', $string, 1, false) . "\n"; // "First"
echo textbetween('<p>', '</p>', $string, 2) . "\n";        // "Second<p>Next Level</p>"
echo textbetween('<p>', '</p>', $string, 3) . "\n";        // "Next Level"
echo textbetween('<p>', '</p>', $string, 4) . "\n";        // ""
echo textbetween('<test>', '</test>', $string) . "\n";     // ""

Changelog

Please see CHANGELOG for more information what has changed recently.

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-14