字符串拆分,当遇到区间时遍历区间内的所有值
程序员文章站
2022-03-11 22:21:38
...
跳至
[1]
[全屏预览]
public function explodes($str){ $return = []; $array = []; foreach(explode(",",$str) as $k => $v){ $return = array_merge($return,(strpos($v,'-') && $array = explode('-',$v))?range($array[0],$array[1]):[$k=>intval($v)]); } return $return; }
下一篇: PHP记住密码功能实现例子