Blogger Information
Blog 28
fans 0
comment 0
visits 65366
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php的explode() 函数将字符串打散为数组
蒸蒸
Original
919 people have browsed it

explode()函数语法:
explode(separator,string,limit)
1.参数separator,必须,规定在哪里分割字符串。
2.参数string,必须,定义要分隔的字符串。
3.参数limit,可选,规定所返回的数组元素的数目。

  1. //基于tp5框架,使用explode()函数分隔字符串,并访问分割后的数组元素
  2. $address='河南省,郑州市,金水区';
  3. $prov=explode(",",$address)[0];
  4. $city=explode(",",$address)[1];
  5. $zone=explode(",",$address)[2];
  6. dump($prov);
  7. dump($city);
  8. dump($zone);

输出结果:
string(9) “河南省”
string(9) “郑州市”
string(9) “金水区”

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post