I have this array:
$arr = array(
0 => array( 'id' => 1, 'animal' => 'dog', 'color' => 'red' ),
1 => array( 'id' => 12, 'animal' => 'cat', 'color' => 'green' ),
2 => array( 'id' => 37, 'animal' => 'lion', 'color' => 'blue' ),
);
and I want this output:
$arr = array(
1 => array( 'animal' => 'dog', 'color' => 'red' ),
12 => array( 'animal' => 'cat', 'color' => 'green' ),
37 => array( 'animal' => 'lion', 'color' => 'blue' ),
);
Any good idea instead of using php loops, etc ?
Any functions? like array_values or array_combine
=================
Possible solution
$new = array();
foreach( $arr as $item ){
$id = array_shift( $item );
$new[$id] = $item;
}
idis arbitrary, so there isn't going to be a function to do this. Everyone's brain just goes straight to the obvious...oh let's loop through that sucker! Then you're like...no loops please....and we're all like ...no.