PHP create array where key and value is same PHP create array where key and value is same arrays arrays

PHP create array where key and value is same


How about array_combine?

$b = array_combine(range(1,10), range(1,10));


Or you did it this way:

$b = array_slice(range(0,10), 1, NULL, TRUE);

Find the output here: http://codepad.org/gx9QH7ES


There is no out of the box solution for this. You will have to create the array yourself, like so:

$temp = array();foreach(range(1, 11) as $n) {   $temp[$n] = $n;}

But, more importantly, why do you need this? You can just use the value itself?