Re: array_push in array maps

From: Date: Wed, 03 May 2006 13:46:29 +0000
Subject: Re: array_push in array maps
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-235368@lists.php.net to get a copy of this message
Jonas Rosling wrote:
Need solve another case regarding array maps. Is it possible to insert more
Jonas - in php we just call these things arrays (no 'map') - the array datatype in php is a mash up (and we love it :-) of the 'oldschool' numerically indexed array and what is commonly known as a hash (or arraymap) - you can mix numeric and associative indexes freely (that might seem odd and/or bad when coming from another language but it really is fantastic once you get your head round it).
values like with array_push in arrays as bellow? $colors = array(
              'red' => '#ff0000',
              'green' => 'X00ff00',
              'blue' => '#0000ff'
           );
sure: $colors['grey'] = '#dedede'; the position of the 'inserted' (actually appended) is often not important - if it is there are plenty of functions that allow you to manipulate arrays in more a complex fashion e.g. array_splice(). and all sorts of sorting functions are also available e.g. asort(). check out the vast number of array related function and introductory texts here: http://php.net/array http://php.net/manual/language.types.array.php
Tanks in advance // Jonas


« previous php.general (#235368) next »