php array_push 向数组增加值函数_PHP教程

WBOY
Release: 2016-07-20 11:06:46
Original
1823 people have browsed it

php array_push 向数组增加值函数
public static function insert(&$array, $key, $newValue, $before = true) {
$result = false;
$size = sizeof($array);
for ($i=0; $i $value = array_shift($array);
if ($i==$key) {
if ($before) {
array_push($array, $newValue);
array_push($array, $value);
} else {
array_push($array, $value);
array_push($array, $newValue);
}
$result = true;
} else {
array_push($array, $value);
}
}
if (!$result) {
array_push($array, $newValue);
}
return;
}


www.bkjia.com true http://www.bkjia.com/PHPjc/445009.html TechArticle php array_push 向数组增加值函数 public static function insert($array, $key, $newValue, $before = true) { $result = false; $size = sizeof($array); for ($i=0; $i$size; $i++)...
Related labels:
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!