angelkurten/string 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

angelkurten/string

最新稳定版本:v0.1

Composer 安装命令:

composer require angelkurten/string

包简介

String is an interface that allows you to interact with a string as if it were an object

README 文档

README

String is an interface that allows you to interact with a string as if it were an object

<?php
  require('String.php');
  
  use AngelKurten\String\String;
  
  $str = new String('If :PARAM is :BOOLEAN increases :TIME');
  
  $array = [':PARAM' => 'cut', ':BOOLEAN' => 'TRUE', ':TIME' => '<b>partially</b>'];
  
  echo  $str->replace($array)->concat('the value of X in 30');

Result: If X is TRUE increases partially the value of X in 30

Examples

Get string length

  echo $str->length();

Reverse a string

  echo $str->invert();

Make a string uppercase

  echo $str->upper();

Make a string lowercase

  echo $str->lower();

Uppercase the first character of each word in a string

  echo $str->upWords();

Make a string's first character uppercase

  echo $str->upFirst();

Make a string's first character lowercase

  • @param integer $limit Number of characters at which the string will be wrapped.
  • @param string $break The line is broken using the optional break parameter.
  • @param bool|true $cut If the cut is set to TRUE, the string is always wrapped at or before the specified width. So if you have a word that is larger than the given width, it is broken apart. When FALSE the function does not split the word even if the width is smaller than the word width.
  echo $str->fragment(75, '<br/>', true);

Replace all occurrences of the search string with the replacement string

  • @param array $array The Value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
  $array = [':PARAM' => 'X', ':BOOLEAN' => 'TRUE', ':TIME' => 'parcialmente'];
  echo  $str->replace($array);

Return part of a string

  • @param integer $start The input string. Must be one character or longer.
  • @param null $length
    • If start is non-negative, the returned string will start at the start'th position in string, counting from zero. For instance, in the string 'abcdef', the character at position 0 is 'a', the character at position 2 is 'c', and so forth.
    • If start is negative, the returned string will start at the start'th character from the end of string.
    • If string is less than start characters long, FALSE will be returned.
  echo  $str->partial(0, 10);

Split a string by string

  • @param string $delimiter The boundary string.
  echo  $str->toArray();

One-way string hashing

  • @param $salt
  echo  $str->hash('enter key here');

Convert all applicable characters to HTML entities

  echo  $str->HtmlToString();

Convert all HTML entities to their applicable characters

  echo  $str->StringToHtml();

Join array elements with a string

  • @param The array or Strings for concat
  echo  $str->concat('the value of X in 30');

Concatenate methods

Methods that can be concatenated are:

  • invert
  • lower
  • upper
  • upWords
  • upFirst
  • downFirst
  • fragment
  • replace
  • partial
  • HtmlToString
  • StringToHtml
  • concat

Example

  echo  $str->concat('the value of X in :VALUE')->upper()->replace([':VALUE' => '100']);

Created By

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-12