当前位置:网站首页>Traps in the explode function in PHP
Traps in the explode function in PHP
2022-07-05 20:56:00 【Fengshen Magic Dragon】
In general , All are carried out when the parameter is not empty explode operation , for example
$a = "a,b,c";
$b = explode(',',$a);
The result will be returned
array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" }
But what if the passed in parameter is empty ?
$a = '';
$b = explode(',',$a);
What results will be returned at this time , Will you think that return
array(0) { }
It's not , It will be returned
array(1) { [0]=> string(0) "" }
If you treat it as a short array , Then all the subsequent logic will go wrong , Because it is not an empty array ,empty It does not return true, So in use explode Be sure to pay attention to the value of the second parameter , It's best to make a non empty judgment first , Later explode operation .
边栏推荐
- ODPs next map / reduce preparation
- ts 之 类的简介、构造函数和它的this、继承、抽象类、接口
- AITM2-0002 12s或60s垂直燃烧试验
- Abnova丨培养细胞总 RNA 纯化试剂盒中英文说明书
- 最长摆动序列[贪心练习]
- Abnova cyclosporin a monoclonal antibody and its research tools
- LeetCode: Distinct Subsequences [115]
- 科普|英语不好对NPDP考试有影响吗 ?
- Interpreting the daily application functions of cooperative robots
- 如何让化工企业的ERP库存账目更准确
猜你喜欢
随机推荐
大二下个人发展小结
示波器探头对测量带宽的影响
Open source SPL eliminates tens of thousands of database intermediate tables
mysql全面解析json/数组
王老吉药业“关爱烈日下最可爱的人”公益活动在南京启动
Material design component - use bottomsheet to show extended content (II)
珍爱网微服务底层框架演进从开源组件封装到自研
Abnova total RNA Purification Kit for cultured cells Chinese and English instructions
Write an interface based on flask
Duchefa丨S0188盐酸大观霉素五水合物中英文说明书
国外LEAD美国简称对照表
phpstudy小皮的mysql点击启动后迅速闪退,已解决
2.<tag-哈希表, 字符串>补充: 剑指 Offer 50. 第一个只出现一次的字符 dbc
Abnova丨E (DIII) (WNV) 重组蛋白 中英文说明书
Return to blowing marshland -- travel notes of zhailidong, founder of duanzhitang
Abbkine丨TraKine F-actin染色试剂盒(绿色荧光)方案
中国管理科学研究院凝聚行业专家,傅强荣获智库专家“十佳青年”称号
Hdu2377bus pass (build more complex diagram +spfa)
Selenium element information
Monorepo management methodology and dependency security