Name
append() 鈥 鎶婂艰拷鍔犲埌鏁扮粍銆
璇存槑
void聽append(mixed聽var);
void聽append(string聽varname,
聽聽聽聽聽聽聽聽聽聽聽聽mixed聽var,
聽聽聽聽聽聽聽聽聽聽聽聽bool聽merge);
鍦ㄨ拷鍔犵殑鏃跺欙紝瀛楃涓插皢杞崲鎴愭暟缁勭殑鍊笺備綘鍙互鏄惧紡浼犻掗敭鍊煎锛屾垨鏄仈鍚堟暟缁勩傚鏋滆缃涓変釜鍙傛暟涓簍rue鏃讹紝璇ュ煎皢鍚堝苟鍒板師鏈夋暟缁勪笂鑰屽苟闈炶拷鍔犮
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 PHP
array_merge()
function
which wipes out numerical keys and renumbers them.
Example聽14.4.聽append()
<?php // 鐩存帴浣跨敤鍜宎ssign()宸笉澶 $smarty->append('foo', 'Fred'); // 杩欓噷锛宖oo宸茬粡鍙樻垚浜嗘ā鏉夸腑鐨勪竴涓暟缁勩 $smarty->append('foo', 'Albert'); $array = array(1 => 'one', 2 => 'two'); $smarty->append('X', $array); $array2 = array(3 => 'three', 4 => 'four'); // 涓嬮潰浼氬鍔犵浜屼釜X鏁扮粍鐨勫厓绱 $smarty->append('X', $array2); // 浼犻掕仈鍚堟暟缁 $smarty->append(array('city' => 'Lincoln', 'state' => 'Nebraska')); ?>