美文网首页
字符串操作

字符串操作

作者: 金色的清晨 | 来源:发表于2016-09-18 14:15 被阅读0次
字符串操作
  • 拼接
  • 截取
  • 长度
  • 相等
  • 包含
  • 替换
  • 去除开头末尾字符串
<?php

$mail = "zw".((string)22)."@gmail.com";
echo $mail, " length:", strlen($mail), "\n";
$first_point = strpos($mail, '@', 1);
$name = substr($mail, 0, $first_point);
if ($name == 'zw22') {
    echo $name, "\n";
}
if (strpos($mail, 'gmail') !== false) {
    echo "exist";
}
echo $first_point, ":", $name, "\n";
echo 'server', ":", substr($mail, $first_point + 1, strlen($mail)), "\n";
$email = "  ".$mail."  \r\n\t";
echo trim($email), "\n";
$bodytag = str_replace("%body%", "black", "<body text='%body%'>");
echo $bodytag;

<h3 id="explode">字符串分割</h3>

php > $result = explode(';','1;2;test');
php > var_dump($result);
array(3) {
  [0]=>
  string(1) "1"
  [1]=>
  string(1) "2"
  [2]=>
  string(4) "test"
}

<h3 id="implode">字符串拼接</h3>

php > $arry = array("1","haha","test");
php > $result= implode(';',$arry);
php > var_dump($result);
string(11) "1;haha;test"

相关文章

  • Python字符串高端操作

    字符串骚操作 字符串优雅操作

  • Python初学(十)

    这章学习下字符串的操作。 字符串的操作 字符串操作符: 针对字符串,Python语言提供了几个基本操作符 字符串处...

  • python 字符串

    字符串操作 + 字符串连接操作 * 字符串复制操作 [] 字符串索引 通过索引访问指定位置的字符,索引从头(0)...

  • Python基础-day06

    list ​ 字符串操作 ​ 字典操作 ​ list操作 字符串操作 编码解码 计算机存储数据使用的是...

  • python函数知识归纳笔记(2)

    字符串相关操作 字符串连接 字符串赋值 [索引值] 字符串通过索引访问位置 从0开始 [::] 字符串取片操作,实...

  • C++之string

    字符串构造和赋值操作 实例 存取字符 实例 字符串拼接操作 实例 字符串查找和替换 实例 字符串比较 实例 字符串...

  • 05-字符串的操作

    字符串的操作方法 [] 字符串索引操作,通过索引访问指定位置的字符,索引从0开始 [::] 字符串取片操作完整格式...

  • Python常用语法二

    Python 字符串操作和文件操作以及其它Python能力补充 Python字符串操作 in和not in: 'x...

  • 【前端】常用的JS知识点整理

    操作数组 操作字符串

  • go strings 和strconv 字符串操作

    strings 字符串操作 strconv 字符串转换 实现基本数据类型转换为 字符串的操作Append 系列...

网友评论

      本文标题:字符串操作

      本文链接:https://www.haomeiwen.com/subject/ryowettx.html