Re: array_push in array maps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux