How to get the first and last record [endereco] in object array and who between this first and last in another new array in codeigniter.
Array (
[0] => stdClass Object ( [id_destino] => 483596 [id_tag] => 0 [endereco] => Belo Horizonte, Minas Gerais [sort] => 0 )
[1] => stdClass Object ( [id_destino] => 483596 [id_tag] => 1 [endereco] => Maricá, Rio de Janeiro [sort] => 1 )
[2] => stdClass Object ( [id_destino] => 483596 [id_tag] => 2 [endereco] => Monte Mor, São Paulo [sort] => 2 ) )
Expected result:
$first_record = [endereco][0]; // "Belo Horizonte, Minas Gerais"
$last_record = [endereco][2]; //in this case will be "Monte Mor, São Paulo"
print_r($new_array); //in this case will just be an array("Maricá, Rio de Janeiro")