• PHP字符串函数


    1.string chunk_split ( string $body [, int $chunklen = 76 [, string $end = " " ]] )将字符串分割成小块
    代码:
    $arr='hello world!';
    $arr=chunk_split($arr,2," ");
    print_r($arr);
    效果:
    he ll o wo rl d!
    2.array explode ( string $delimiter , string $string [, int $limit ] )
    3.string implode ( string $glue , array $pieces )
      string implode ( array $pieces )将一个一维数组的值转化为字符串
    4. 大小写转换函数
    4.1. ucfirst(string $str) - 将字符串的首字母转换为大写
    4.2. string strtolower ( string $str ) - 将字符串转化为小写
    4.3. strtoupper(string $str) - 将字符串转化为大写
    4.4. ucwords(string $str) - 将字符串中每个单词的首字母转换为大写
    4.5.string lcfirst ( string $str )使一个字符串的第一个字符小写
    5.
    5.1.string ltrim ( string $str [, string $charlist ] )删除字符串开头的空白字符(或其他字符)
    string trim ( string $str [, string $charlist = " x0B" ] )
    " " (ASCII 32 (0x20)),普通空白字符。
    2. " " (ASCII 9 (0x09)), 制表符.
    3. " " (ASCII 10 (0x0A)),换行符。
    4. " " (ASCII 13 (0x0D)),回车符。
    5. "" (ASCII 0 (0x00)), NUL空字节符。
    6. "x0B" (ASCII 11 (0x0B)),垂直制表符。
    6.字符串算法
    6.1.md5(string $str [, bool $raw_output = false ]) — 计算字符串的 MD5 散列值
    6.2.md5_file() - 计算指定文件的 MD5 散列值
    6.3.sha1_file() - 计算文件的 sha1 散列值
    6.4.crc32() - 计算一个字符串的 crc32 多项式
    6.5. sha1() - 计算字符串的 sha1 散列值
    6.6. hash() - Generate a hash value (message digest)
    7.string number_format ( float $number [, int $decimals = 0 ] )以千位分隔符方式格式化一个数字
    8.mixed str_ireplace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )
      mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )
      string strtr ( string $str , string $from , string $to )转换指定字符
      string strtr ( string $str , array $replace_pairs )
      mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )执行一个正则表达式的搜索和替换
     
    9.string str_pad ( string $input , int $pad_length [, string $pad_string = " " [, int $pad_type = STR_PAD_RIGHT ]] )
    10.string str_repeat ( string $input , int $multiplier )
    11.string str_shuffle ( string $str )随机打乱一个字符串
    12.array str_split ( string $string [, int $split_length = 1 ] )将字符串转换为数组
    13.mixed str_word_count ( string $string [, int $format = 0 [, string $charlist ]] )返回字符串中单词的使用情况
    14.string strip_tags ( string $str [, string $allowable_tags ] )从字符串中去除 HTML 和 PHP 标记
    15.int stripos ( string $haystack , string $needle [, int $offset = 0 ] )
       int strpos ( string $haystack , string $needle [, int $offset = 0 ] )查找字符串首次出现的位置
       int strripos ( string $haystack , string $needle [, int $offset = 0 ] )计算指定字符串在目标字符串中最后一次出现的位置(不区分大小写)
       int strrpos ( string $haystack , string $needle [, int $offset = 0 ] )
       string strstr ( string $haystack , mixed $needle [, bool $before_needle = false ] )查找字符串的首次出现
       
    16.int strlen ( string $string )
    17.string stristr ( string $haystack , mixed $needle [, bool $before_needle = false ] )
       string strstr ( string $haystack , mixed $needle [, bool $before_needle = false ] )
    18.string strrchr ( string $haystack , mixed $needle )
    19.string strrev ( string $string )反转字符串
    20.int substr_count ( string $haystack , string $needle [, int $offset = 0 [, int $length ]] )
    21.string substr ( string $string , int $start [, int $length ] )返回字符串的子串
    22.string wordwrap ( string $str [, int $width = 75 [, string $break = " " [, bool $cut = false ]]] )打断字符串为指定数量的字串

  • 相关阅读:
    Use the Microsoft C++ toolset from the command line
    libeay32.dll 和 ssleay32.dll 在1.1.0之后没有了
    libeay32.dll 1.0.2j crash
    VHD VHDX 区别
    char * 转 wchar *
    C++ 0xC0000094: Integer division by zero
    爬取人人网
    伪造请求头向url传递参数爬取百度默认翻译
    爬取百度贴吧
    urllib爬取实例
  • 原文地址:https://www.cnblogs.com/ymk0375/p/6550736.html
Copyright © 2020-2023  润新知