• <基础> PHP 字符串操作


    explode — 使用一个字符串分割另一个字符串 

    array explode ( string $delimiter , string $string [, int $limit ] )

    implode — 将一个一维数组的值转化为字符串

    string implode ( string $glue , array $pieces )

    htmlspecialchars — 将特殊字符转换为 HTML 实体  (XXS)

    string htmlspecialchars ( string $string )

    htmlspecialchars_decode — 将特殊的 HTML 实体转换回普通字符 (与 htmlspecialchars 相反)

    string htmlspecialchars_decode ( string $string )

    strip_tags — 从字符串中去除 HTML 和 PHP 标记(和htmlspecialchars不同的是 strip_tags 是直接去除标记,而前者是转义成另外的字符) 

    string strip_tags ( string $str [, string $allowable_tags ] )

    md5 — 计算字符串的 MD5 散列值

    string md5 ( string $str [, bool $raw_output = false ] )

    nl2br — 在字符串所有新行之前插入 HTML 换行标记 (能将浏览器不能识别的 或者 转化成 </br>)

    string nl2br ( string $string [, bool $is_xhtml = TRUE ] )

    trim — 去除字符串首尾处的空白字符(或者其他字符)

    string trim ( string $str [, string $character_mask = " 	
    
    x0B" ] )

    strpos — 查找字符串首次出现的位置(stripos 不区分大小写)(通常用于判断字符串中是否包含另一个字符串

    int stripos ( string $haystack , string $needle [, int $offset = 0 ] )

    strrpos — 计算指定字符串在目标字符串中最后一次出现的位置

    int strrpos ( string $haystack , string $needle [, int $offset = 0 ] )

    strstr — 查找字符串的首次出现 返回第一次出现的位置开始到 haystack 结尾的字符串

    string strstr ( string $haystack , mixed $needle [, bool $before_needle = FALSE ] )

    strrchr — 查找指定字符在字符串中的最后一次出现

    string strrchr ( string $haystack , mixed $needle )

    strlen — 获取字符串长度(也可以用来判断字符串是否为空)

    int strlen ( string $string )

    strtolower — 将字符串转化为小写

    string strtolower ( string $string )

    strtoupper — 将字符串转化为大写

    string strtoupper ( string $string )

    substr_count — 计算字串出现的次数

    int substr_count ( string $haystack , string $needle [, int $offset = 0 [, int $length ]] )

    substr — 返回字符串的子串(返回字符串 string 由 start 和 lenth 参数指定的子字符串)

    string substr ( string $string , int $start [, int $length ] )

    str_replace — 子字符串替换(忽略大小写请用 str_ireplace

    mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )

    search

    查找的目标值,也就是 needle。一个数组可以指定多个目标。

    replace

    search 的替换值。一个数组可以被用来指定多重替换。

    subject

    执行替换的数组或者字符串。也就是 haystack

    如果 subject 是一个数组,替换操作将遍历整个 subject,返回值也将是一个数组。

    count

    如果被指定,它的值将被设置为替换发生的次数。

     

  • 相关阅读:
    textspan 转连接
    showDialog 必须Stateful
    SliverList , SliverFixedExtentList
    sliver
    [UWP]UIElement.Clip虽然残废,但它还可以这样玩
    [UWP]用Win2D和CompositionAPI实现文字的发光效果,并制作动画
    [UWP]用Win2D实现镂空文字
    [UWP]通过自定义XamlCompositionBrushBase实现图片平铺
    [UWP]使用Win2D的BorderEffect实现图片的平铺功能
    [UWP]使用CompositionAPI的翻转动画
  • 原文地址:https://www.cnblogs.com/xiaoliwang/p/8775606.html
Copyright © 2020-2023  润新知