?
Dieses Dokument verwendet PHP-Handbuch für chinesische Websites Freigeben
void append
(mixed
var)
void append
(string
varname, mixed var)
void append
(string
varname, mixed var, boolean merge)
This is used to append an element to an assigned array. If you
append to a string value, it is converted to an array value and then
appended to. You can explicitly pass name/value pairs, or associative
arrays containing the name/value pairs. If you pass the optional third
parameter of true, the value will be merged with the current array
instead of appended.
添加指定的元素到數(shù)組中。如果是添加一個(gè)字符串,該字符串會(huì)被轉(zhuǎn)換為數(shù)組格式后再進(jìn)行添加。所添加的數(shù)據(jù)可以采用 名稱, 數(shù)值
的格式,或者是使用 “=>”連接的聯(lián)合數(shù)組格式。如果第三個(gè)可選參數(shù)被指定為
TRUE,所添加的數(shù)據(jù)會(huì)和數(shù)組中現(xiàn)有數(shù)據(jù)進(jìn)行合并,而不是直接添加。
Technical Note: The merge parameter respects array keys, so if you merge two numerically indexed arrays, they may overwrite each other or result in non-sequential keys. This is unlike the array_merge() function of PHP which wipes out numerical keys and renumbers them.
注意:使用第三個(gè)參數(shù)“merge”時(shí)要考慮到數(shù)組的索 引,所以,如果添加和被添加的數(shù)組都是以數(shù)字為索引,他們會(huì)互相覆蓋,或者產(chǎn)生不連續(xù)的索引。這并不象PHP中的array_merge()函數(shù),后者會(huì) 刪除原有的數(shù)字索引,重新對(duì)索引進(jìn)行編號(hào)。
Example 13-1. append 例子 13-1. 添加
|