World Of Webmaster
Đăng nhập / Đăng ký
Account
Free for web
Check pagerank
Input check pager (Not http://)

Ext: blog.kai.vn
Check google pagerank
View HTML source
FUNCTION LIBRARY
HTML Tags Library
PHP Functions Library ASP Functions Library
PHP Functions array_splice
Chức năng: Xóa một vài phần tử mảng và thay thế bằng các phần tử khác
Ngôn ngữ: php - Nhóm: array
CÚ PHÁP
 array array_splice ( array &$input, int $offset [, int $length [, array $replacement]] );

Hàm xóa đi một vài phần tử của mảng và có thể thay thế vào đó những phần tử mới do người sử dụng định nghĩa ở các đối số:
INPUT: Mảng đưa vào để xữ lý.
OFFSET: Vị trí xác định việc xóa bỏ phần tử.
+ Nếu OFFSET > 0, mảng được xóa từ vị trí bắt đầu,
+ Nếu OFFSET < 0, mảng được xóa từ vị trí cuối.
LENGTH: Số phần tử bị xóa kể từ vị trí.
REPLACEMENT: Mảng được đưa vào để thêm vào mảng INPUT. Mảng INPUT chỉ được xữ lý thêm vào khi mảng REPLACEMENT tồn tại.
Một vài cách xữ lý tương được với việc sử dụng hàm này:

 array_push($input, $x, $y);
 array_splice($input, count($input), 0, array($x, $y));

 array_pop($input);
 array_splice($input, -1);

 array_shift($input);
 array_splice($input, 0, 1);

 array_unshift($input, $x, $y);
 array_splice($input, 0, 0, array($x, $y));

 $input[$x] = $y;	 // for arrays where key equals offset
 array_splice($input, $x, 1, $y);

VÍ DỤ
<?php
$input 
= array("red""green""blue""yellow");
array_splice($input2);
// $input is now array("red", "green")

$input = array("red""green""blue""yellow");
array_splice($input1, -1);
// $input is now array("red", "yellow")

$input = array("red""green""blue""yellow");
array_splice($input1count($input), "orange");
// $input is now array("red", "orange")

$input = array("red""green""blue""yellow");
array_splice($input, -11, array("black""maroon"));
// $input is now array("red", "green",
//          "blue", "black", "maroon")

$input = array("red""green""blue""yellow");
array_splice($input30"purple");
// $input is now array("red", "green",
//          "blue", "purple", "yellow");
?>

array_multisort
array_pad
array_pop
array_push
array_rand
array_reduce
array_reverse
array_search
array_shift
array_slice
Library ›› HTML Tag | PHP Function | ASP Function
Page : 806800
Online :
Visited : 370123
 
Liên h | Thêm vào Favorite | Gửi link qua e-mail | Thông tin website
Copright © 2009 KAI Blog
Code by BOINGOnline. Contact email : contact@kai.vn
Theme: default | classic |