Convert a 2D array in 1D array..
App::Utility()->get1DArr(Array, Key, Value)
Parameter |
Description |
---|---|
Array |
Source 2D Array |
Key |
Field to set as a new Array index |
Value |
Field to set as a new Array value |
See bellow example:
$arr[] = array("id"=>5, "name"=>"Jhon","grad"=>'A');
$arr[] = array("id"=>10, "name"=>"Khan","grad"=>'A');
$arr[] = array("id"=>15, "name"=>"Zaman","grad"=>'B');
$arr[] = array("id"=>20, "name"=>"Zarir","grad"=>'D');
$data = App::Utility()->get1DArr($arr,'id','name');
pre($data);
/*
Return data
Array
(
[5] => Jhon
[10] => Khan
[15] => Zaman
[20] => Zarir
)*/