SEO学院

大理石构件

php切割字符串

explode

 

语法

explode(separator,string,limit)

separator 必需。规定在哪里分割字符串。
string 必需。要分割的字符串。
limit

可选。规定所返回的数组元素的数目。

可能的值:

  • 大于 0 - 返回包含最多 limit 个元素的数组
  • 小于 0 - 返回包含除了最后的 -limit 个元素以外的所有元素的数组
  • 0 - 返回包含一个元素的数组

 

实例:从完整url中匹配切割出域名

$str = "https://www.miqile.cn/favorites/xuexijiaocheng";

$str1=explode('/',$str);

因为explode返回的是数组,所以获取域名只需要用  $str1[2]即可

 

原文:http://www.cuteur.cn/post/1692.html

 

posted @ 2020-10-07 16:57  cute12  阅读(444)  评论(0编辑  收藏  举报

PHP知识网

眯起了导航网

大理石平台