On Fri, Sep 14, 2012 at 2:30 AM, Matijn Woudt <tijn...@gmail.com> wrote:
> It doesn't need to be clunky.. just use array_flip and you've got the old
> array again..

Well, array_flip has it's own potential issues (duplicate values are
lost, so my example of using zeros would not work.) I suppose I could
duplicate the keys as the values (e.g., array('value 1' => 'value 1',
'value 2' => 'value 2', ...).) Then, the keys would  allow me to
utilize the nice properties of hash maps whilst maintaining the
ability to work with the values as one normally does in typical array


$a1 = array('apples' => 'apples', 'oranges' => 'oranges', 'pears' => 'pears');
$a2 = array('oranges' => 'oranges', 'kiwi' => 'kiwi');
// can use the union operator without any additional calls and the
performance is stellar
$a3 = $a1 + $a2
// can use the values of the array using the convention that the value
is what you expect to handle/manipulate
foreach ($a3 as $val) {
  echo $val

Here, the clunkiness is the redundancy in the array, but, as Claude
Shannon has demonstrated, redundancy isn't all bad :)


Nephtali:  A simple, flexible, fast, and security-focused PHP framework

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

Reply via email to