explode()函数语法:
explode(separator,string,limit)
1.参数separator,必须,规定在哪里分割字符串。
2.参数string,必须,定义要分隔的字符串。
3.参数limit,可选,规定所返回的数组元素的数目。
//基于tp5框架,使用explode()函数分隔字符串,并访问分割后的数组元素$address='河南省,郑州市,金水区';$prov=explode(",",$address)[0];$city=explode(",",$address)[1];$zone=explode(",",$address)[2];dump($prov);dump($city);dump($zone);
输出结果:
string(9) “河南省”
string(9) “郑州市”
string(9) “金水区”
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号