PHP中substr函数如何使用?

PHP中substr函数的作用是返回字符串的一部分,其语法为“substr(string,start,length)”,其参数string表示返回其中一部分的字符串,参数start表示在字符串的何处开始,参数length表示截取长度。

创新互联公司专业为企业提供南湖网站建设、南湖做网站、南湖网站设计、南湖网站制作等企业网站建设、网页设计与制作、南湖企业网站模板建站服务,十年南湖做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

使用示例

";
echo substr("Hello world",1)."
"; echo substr("Hello world",3)."
"; echo substr("Hello world",7)."
"; echo substr("Hello world",-1)."
"; echo substr("Hello world",-10)."
"; echo substr("Hello world",-8)."
"; echo substr("Hello world",-4)."
"; ?>
";
echo substr("Hello world",1,8)."
"; echo substr("Hello world",0,5)."
"; echo substr("Hello world",6,6)."
"; echo substr("Hello world",0,-1)."
"; echo substr("Hello world",-10,-2)."
"; echo substr("Hello world",0,-6)."
"; echo substr("Hello world",-2-3)."
"; ?>

推荐教程:《PHP》
网站名称:PHP中substr函数如何使用?
新闻来源:http://csruizhi.cn/article/cpppec.html

其他资讯

Copyright © 2007-2024 成都优众联杰科技有限公司 All Rights Reserved 蜀ICP备2024116266号
友情链接: 成都网站制作 上市集团网站建设 成都网站制作 外贸营销网站建设 成都网站建设公司 成都网站制作 营销网站建设 手机网站建设套餐 成都网站建设 重庆外贸网站建设 梓潼网站设计 成都网站建设 营销型网站建设 成都网站建设 自适应网站建设 成都网站设计 网站建设改版 成都网站建设 成都响应式网站建设 成都营销网站制作 手机网站制作 定制网站建设