phparray_push向数组增加值函数_PHP教程
                        
                            时间:2021-07-01 10:21:17
                            帮助过:3人阅读
							                        
                     
                    
                    php  array_push 向数组增加值函数
 public static function insert(&$array, $key, $newValue, $before = true) {
  $result = false;
  $size = sizeof($array);
  for ($i=0; $i<$size; $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;
 }	
	
http://www.bkjia.com/PHPjc/445009.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445009.htmlTechArticlephp array_push 向数组增加值函数 public static function insert($array, $key, $newValue, $before = true) { $result = false; $size = sizeof($array); for ($i=0; $i$size; $i++)...