[ create a new paste ] login | about

Link: http://codepad.org/1StYWY5Q    [ raw code | output | fork ]

PHP, pasted on Mar 5:
1
2
3
4
5
6
7
8
9
10
11
12
13
<?
$orig_array = array('green','blue','orange','blue');
$array = array_flip($orig_array);
/* Same as first example, except now we first extract array keys */

$array = array_flip(array_keys($array));

//original was this
print_r($array);


//what you really want is this
print_r(array_keys(array_flip($orig_array)));


Output:
1
2
3
4
5
6
7
8
9
10
11
12
Array
(
    [green] => 0
    [blue] => 1
    [orange] => 2
)
Array
(
    [0] => green
    [1] => blue
    [2] => orange
)


Create a new paste based on this one


Comments: