当前位置:网站首页>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 .
边栏推荐
猜你喜欢
随机推荐
Monorepo管理方法论和依赖安全
When a user logs in, there is often a real-time drop-down box. For example, entering an email will @qq com,@163. com,@sohu. com
《SAS编程和数据挖掘商业案例》学习笔记# 19
木板ISO 5660-1 热量释放速率摸底测试
ts 之 泛型
ProSci LAG-3 重组蛋白说明书
php中explode函数存在的陷阱
AITM 2-0003 水平燃烧试验
Mathematical analysis_ Notes_ Chapter 9: curve integral and surface integral
SQL series (basic) - Chapter 2 limiting and sorting data
XML建模
Abnova DNA marker high quality control test program
MYSQL IFNULL使用功能
Graph embedding learning notes
ViewRootImpl和WindowManagerService笔记
Is it safe to open a stock account by mobile phone? My home is relatively remote. Is there a better way to open an account?
使用WebAssembly在浏览器端操作Excel
获取前一天的js(时间戳转换)
驱动壳美国测试UL 2043 符合要求有哪些?
leetcode:1139. 最大的以 1 为边界的正方形