-1

How to make an array.I have array like this

Array
(
[0] => Array
    (
        [id_facility_master] => 2
    )

[1] => Array
    (
        [id_facility_master] => 3
    )

[2] => Array
    (
        [id_facility_master] => 6
    ))

It's returned from codeigniter active record so i want change format by the array values like this

$arr = array(2,3,6);

2 Answers2

1

you can use array_column

$results= array_column($yourarray, 'id_facility_master');
Sugumar Venkatesan
  • 3,782
  • 7
  • 39
  • 71
0

Use array_map function

function generate($arr){
   return $arr['id_facility_master'];
}

$res = array_map('generate', $data)
Pranav C Balan
  • 110,383
  • 23
  • 155
  • 178