PHP中保留key值把value置0,嵌套数组可用

WBOY
Release: 2016-06-23 13:35:01
Original
1094 people have browsed it

实现一个把PHP数组中所有元素设置为0的函数,用了递归

public  function setArraytoZero(&$array) {        foreach ($array as &$value){            if(is_array($value)) {                $this->setArraytoZero($value);            }            else {                $value = 0;            }        }    }
Copy after login


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template