note 31621 added to ref.array

From: Date: Mon, 28 Apr 2003 11:55:35 +0000
Subject: note 31621 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-47202@lists.php.net to get a copy of this message
this simple function will append array $a2 to array $a1 and return the total number of elements added function array_append(&$a1, $a2) { if( !is_array($a1) || !is_array($a2) ) return 0; foreach( $a2 as $val ) $a1[] = $val; return count($a2); } Ex: $arr = array(1,2,3,4); array_append($arr, array(5,6,7,8)); print_r($arr); Output ------ Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 ) -- http://www.php.net/manual/en/ref.array.php http://master.php.net/manage/user-notes.php?action=edit+31621 http://master.php.net/manage/user-notes.php?action=delete+31621 http://master.php.net/manage/user-notes.php?action=reject+31621

« previous php.notes (#47202) next »