strchr()主要有2个最有用的用法:

第一个:搜索字符串在另一字符串中的第一次出现。并返回剩余的部分

$str = "hello_chrdai_1993";
$not_include_hello = strchr($str,'_');
echo $not_include_hello; // _chrdai_1993

第一个:搜索字符串在另一字符串中的第一次出现。并返回第一次出现之前的字符串部分

$str = "hello_chrdai_1993";
$not_include_hello = strchr($str,'_',true); // 注意,此处加了一个参数 true, php > 5.3 才能用这个参数
echo $not_include_hello; // hello

本文为我工作中记录的收获,如有转载,请注明出处http://www.cnblogs.com/chrdai/p/7241384.html

strchr()的更多相关文章

  1. strchr()函数 和 strrchr() 函数

    strchr 定义于头文件 <string.h>char *strchr( const char *str, int ch );寻找ch(按照如同(char)ch的方式转换成char后)在 ...

  2. C语言strchr()函数:查找某字符在字符串中首次出现的位置

    头文件:#include <string.h> strchr() 用来查找某字符在字符串中首次出现的位置,其原型为:    char * strchr (const char *str, ...

  3. strstr strchr strrchr

    通过函数的定义来区分: 1.strstr: 返回子串出现的第一次位置 char *strstr(const char *haystack, const char *needle) 可见,strstr函 ...

  4. PHP字符串函数之 strstr stristr strchr strrchr

    strstr -- 查找字符串的首次出现,返回字符串从第一次出现的位置开始到该字符串的结尾或开始. stristr -- strstr 函数的忽略大小写版本 strchr -- strstr 函数的别 ...

  5. strstr,strchr,strtr 比较

    strstr - 查找字符串的首次出现 查找 "Shanghai" 在字符串中的第一次出现,并返回字符串的剩余部分: echo strstr("I love Shangh ...

  6. c语言,strchr(),查找字符串中第一次字符出现的位置

    int main(void) { char string[15]; char *ptr, c = 's'; strcpy(string, "This is a string"); ...

  7. hdu1106 字符串水题strtok()&&strchr()&&sscanf()+atoi()使用

    字符串的题目 用库函数往往能大大简化代码量 以hdu1106为例 函数介绍 strtok() 原型: char *strtok(char s[], const char *delim); 功能: 分解 ...

  8. strchr,wcschr 和strrchr, wcsrchr,_tcschr,_tcsrchr功能

           strchr,wcschr 和strrchr, wcsrchr,_tcschr,_tcsrchr功能 (1) char *strchr( const char *string, int ...

  9. strchr,wcschr 及strrchr, wcsrchr,_tcschr,_tcsrchr函数

           strchr,wcschr 及strrchr, wcsrchr,_tcschr,_tcsrchr函数 (1) char *strchr( const char *string, int ...

  10. base(function strchr)

    函数原型:extern char *strchr(char *str,char character) 参数说明:str为一个字符串的指针,character为一个待查找字符.        所在库名: ...

随机推荐

  1. LightOJ - 1245 Harmonic Number (II) 求同值区间的和

    题目大意:对下列代码进行优化 long long H( int n ) {    long long res = 0;    for( int i = 1; i <= n; i++ )      ...

  2. Thymeleaf在前台下拉列表获取后台传的值

    Thymeleaf在前台下拉列表获取后台传的值 后台添加代码: /** * 新增机构 */ @GetMapping("/add") public String add(ModelM ...

  3. truncate、delete、drop区别

    语法: truncate table 表名 delete from 表名 drop table 表名 应用范围: truncate 只能对表,且不能用于参与了索引的表,不能用于外键约束引用的表 del ...

  4. 3. Python 字典 常用办法总结

    Python字典客储存任意类型的对象,如字符串.数字.元祖.列表.字典.bool等. 优点:取值方便,速度快 1.创建字典 字典由键(key)和对应值(value)成对组成. 字典也被称作关联数组或哈 ...

  5. 基于tiny4412的Linux内核移植 -- 设备树的展开【转】

    转自:https://www.cnblogs.com/pengdonglin137/p/5248114.html#_lab2_3_1 阅读目录(Content) 作者信息 平台简介 摘要 正文 一.根 ...

  6. Cent os 6.8添加中文字体

    作者:邓聪聪 Cent os 6.8添加中文字体的相关步骤: [root@bogon ]#yum -y install fontconfig #yum安装fontconfig [root@bogon ...

  7. Json的序列化与反序列化以及乱入的k_BackingField

    0.Newtonsoft.json 最简单的最强大的基于c#的json解析库是Newtonsoft.json 在NuGet程序包管理器中在线搜索“json”,选择JSon.Net,并安装.   使用到 ...

  8. MFCWinInet学习

    http://blog.csdn.net/segen_jaa/article/details/6278167 背景: 功能:服务端下载文件 服务端:用Java写Sevlet进行有效性验证 客户端:用C ...

  9. 18春季训练01-3/11 2015 ACM Amman Collegiate Programming Contest

    Solved A Gym 100712A Who Is The Winner Solved B Gym 100712B Rock-Paper-Scissors Solved C Gym 100712C ...

  10. Go Rand小结

    对于Random的使用,在业务中使用频率是非常高的,本文就小结下常用的方法: 在Golang中,有两个包提供了rand,分别为 "math/rand" 和 "crypto ...