<?php
/**
* Created by 郭鹏.
* User: msi
* Date: 2017/9/27
* Time: 14:17
*/
//随机数生成器
echo rand();
echo "<br>";
//生成某个范围随机数
echo rand(0,10);
echo "<br>";
//获取当前时间戳
echo time();
echo "<br>";
//格式化显示时间
echo "<br>";
echo date("Y-m-d H:i:s",time());
echo "<br>";
echo date("Y-m-d H:i:s","1506494976");
//字符串转换成时间戳
echo "<br>";
echo strtotime("2017-09-27 14:37:39");
echo "<br>";
//取字符串的长度
$str1 = "abcdefg";
$str2 = "abc";
//echo strlen();
echo "<br>";
//比较两个字符串,美国信息交换标准代码;
var_dump(strcmp($str1,$str2));
//转小写
echo "<br>";
strtolower($str2);
//转大写
//strtoupper();
//拆分字符串
echo "<br>";
var_dump(explode("b",$str2));
//将数组元素拼接成一个字符串
echo "<br>";
echo implode("|",["a","b","c"]);
//替换替换
echo "<br>";
//这里拿到是返回值,所以要用到echo输出一下;
echo str_replace("cd","CD",$str1);
echo "<br>";
echo $str1;
//替换指定位置的字符串
echo "<br>";
echo substr_replace($str1,"xxx",0,3);
//截取字符串
echo "<br>";
echo substr($str1,1,3);
//正则表达式
$str =<<<A
456abcdefghijklmn123
A;
echo "<br>";
//上述所有字符的数字替换成#
echo preg_replace("/d/","#",$str);
echo "<br>";$zxc = <<<askadjkasdkasjdaklsdnkas123a;echo preg_replace("/d/","#",$zxc);
echo "<br>";
echo substr($zxc,3,10);
echo "<br>";
echo substr_replace($zxc,"skazxc",1,6);
echo "<br>";
echo substr($zxc,1,6);
echo "<br>";echo $zxc;
echo substr_replace();