承接 eissaweb/php-html-text-content 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

eissaweb/php-html-text-content

Composer 安装命令:

composer require eissaweb/php-html-text-content

包简介

Change HTML text content using PHP.

README 文档

README

With this package you can change textContent of HTML tag.

install using composer

composer require eissaweb/php-html-text-content:0.1

Examples:

#1 Using String as a parameter

<?php 

require_once 'vendor/autoload.php';

use PHPHtmlTextContent\ReplaceTextContent;

$str = '<div>Hello World!!2</div></p>New Line 2</p>';
// ReplaceTextContent::replace($str, $search, $replace, $callback = null);
$replaced = ReplaceTextContent::replace($str, '2', '');

echo $replaced;
//Hello World!!
// New Line

#2 using array of string as a parameter

<?php 

require_once 'vendor/autoload.php';

use PHPHtmlTextContent\ReplaceTextContent;

$str = '<div>Hello World??2</div>';
// ReplaceTextContent::replace($str, $search, $replace, $callback = null);
$replaced = ReplaceTextContent::replace($str, ['2', '?'], ['', '!']);

echo $replaced;
// Hello World!!

#3 passing callback

you can pass callback as 4th parameter to modify the replaced string.

<?php 

require_once 'vendor/autoload.php';

use PHPHtmlTextContent\ReplaceTextContent;

$str = '<div>Hello World??2</div><div class="username"><a href="github.com/eissaweb">Eissaweb??</a></div>';
// ReplaceTextContent::replace($str, $search, $replace, $callback = null);
$replaced = ReplaceTextContent::replace($str, ['2', '?'], ['', '!'], function ($replacedStr) {
    // in this case you can style the replaced text by using inline style or adding html classes to the tag as you want.
    return '<span>' . $replacedStr . '</span>';
});

echo $replaced;
// Hello World!!
// Eissaweb!!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固