note 30322 modified in function.array-push by vrana

From: Date: Tue, 17 Aug 2004 14:48:18 +0000
Subject: note 30322 modified in function.array-push by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-79757@lists.php.net to get a copy of this message
Just to fix and clean up the above example... it should be: <?php function addArray(&$array, $key, $val) { $tempArray = array($key => $val); $array = array_merge ($array, $tempArray); } ?> and use this to view them: <?php foreach ($myArray as $key=>$val) { echo "key = ".$key." val = ".$val; } ?> --was-- Just to fix and clean up the above example... it should be: function addArray(&$array, $key, $val) { $tempArray = array($key => $val); $array = array_merge ($array, $tempArray); } and use this to view them: foreach ($myArray as $key=>$val) { echo "key = ".$key." val = ".$val; } http://php.net/manual/en/function.array-push.php

« previous php.notes (#79757) next »