const br = '<br/>';
//常見函數調用
echo strlen('hahah ninhao').br; //統計字符串长度 //打印12
echo strpos('haohaoxuexitiantianxiangshang','xi').br; //查看xi字符串首次出现的位置 //打印9
echo str_replace('xi','biancheng','haohaoxuexi').br; //替换字符串xi为编程 //打印haohaoxuebiancheng
print_r(explode(',','hello,word')); //将字符串hello,word以逗号作为切割符,转换字符串为数组 //打印Array ( [0] => hello [1] => word )
echo br;
$arr = ['hao','hao','xue','xi'];
echo implode(',',$arr).br; //将数组以,作为分隔符,转换为数组; //打印hao,hao,xue,xi
echo strcmp('haha','hahaha').br; //用于判断两个字符串大小,左边长度长为正,右边长度长为负; //打印-2
echo abs(-99).br; //取绝对值 //打印9
echo ceil(7.77).br; //向上取整 //打印8
echo floor(7.77).br; //向下取整 //打印7
echo rand(1,20).br; //取1-20随机数字
echo time().br; //获取当前时间戳
echo date('Y-m-d H:i:s').br; //获取当前时间
$a = ['a','b','c'];
$b = ['d','e','f'];
print_r(array_combine($a,$b)); //合并两个数组,将a数组设置为键,b数组设置为值 //打印Array ( [a] => d [b] => e [c] => f )
echo br;
$c = [123,321,22,12];
rsort($c); //对数组进行由高到低排序
print_r($c); //打印Array ( [0] => 321 [1] => 123 [2] => 22 [3] => 12 )
echo br;
$d = ['zhangsan','lisi'];
array_push($d, 'wangwu','chengliu'); //向数组d中添加两个元素
print_r($d); //打印Array ( [0] => zhangsan [1] => lisi [2] => wangwu [3] => chengliu )
echo br;
unset($d[2]); //删除某2索引的元素
print_r($d); //打印Array ( [0] => zhangsan [1] => lisi [3] => chengliu )
echo br;
$d[0] = 'zhangqiqiang'; //将0索引的值修改为zhangqiqiang
print_r($d); //打印Array ( [0] => zhangqiqiang [1] => lisi [3] => chengliu )
echo br;
效果展示