I want to turn plain array into two dimensional array. I can do it with a code below but is there native PHP function to handle it. I went through the manual and wen but didn't see anything.
Thanks
$array = array('a', 'b');
Should be converted into:
$array = array('a'=>'a', 'b'=>'b');
I don't want to use this if there is a simple function:
foreach($array as &$value)
{
$new[$value] = $value;
}
You can use array_combine()
, which combines (suprisingly enough) an array of keys and an array of values into a single array.
$array = array_combine($array, $array);