Arrays with unique entries
From MapbenderWiki
The goal is to delete multiple occurences of an item in an array.
Example:
[0] => 1 [1] => 2 [2] => 1 [3] => 3
shall be changed into
[0] => 1 [1] => 2 [2] => 3
Contents |
[edit]
PHP
[edit]
array_unique
see php.net. This function preserves the keys, the above would be changed into
[0] => 1 [1] => 2 [3] => 3
which is disastrous if you use for and not foreach
[edit]
array_keys, array_flip
the following does not preserve the keys
array_keys( array_flip( someArray ));
so the result would indeed be
[0] => 1 [1] => 2 [2] => 3
[edit]
JavaScript
no solution yet.

