php - Reducing multidimensional array to linear -
I have asked a question like this but have not replied. Im guessing because it was too long that I was not fully able to clarify it for the state or the general public. Array ([0] => array ([ID] => name) [1] => array ([ID] => is to reduce the array as name))
The above Price came from.
$ query = $ this- & gt; Db - & gt; Select ('id, name') - & gt; From ('Employee') - & gt; Received () - & gt; Result_are ();
results given above,
array ([0] => array ([ID] => 1 [name] => john) / P>
Because I wanted to get all the rows without overwriting the previous lines. I added this alga.
foreach ($ query as line $) {$ Employee_list [] = Array ($ line ['id'] = & gt; $ row ['name']);}
Now the results are not overwritten, if I print_r ($ employee_list);
I would like to echo out, assuming that my employee is talc There are 2 rows. ([1] => Array ([1] => zone) [2] => Array ([2] = 1)> Peter)
My question Now, how do I reduce the array as a one-dimensional / linear result as the ID is stored as a key and the id column is a one-time auto inertment primary key, so there is no duplicate in it, which means That's the ID increases in each line.
I wanted to
Array ([1] => zone [2] => peter)
Additional information: I'm using Codeigniter to framework, so if There is a defined function in the CI library, so if someone tells me if someone is there, it will help.
In the old time you can use which one column chooses in a single-dimensional array.
However, it has been deprecated since PHP 5.5.0 and has been suggested to use the reference (which forces you to make a selection in response to zerkms comments) or If you are ready to use the PDO
Comments
Post a Comment