How Do I Merge Three Columns From A Csv File To Give Me A Single Column With Php
I am importing a CSV file that has 3 adjacent columns lets call them Size, Color and Item. I need to combine these columns and have one long column that has all these value WHILST stripping out the rows that have a no content in them.
I am still having trouble combining the two thus far.
Have tried array_merge and so forth but i get no love.
$a = array($data[4]);
$b = array($data[5]);
$result = array_me开发者_开发问答rge((array)$a, (array)$b);
print_r($result);
with $data[4]
and $data[5]
being the csv columns
my result is:
Array (
[0] => Size
[1] => Colour
)
Array (
[0] => Large
[1] => Black
)
Array (
[0] => Medium
[1] => Black
)
Array (
[0] => Small
[1] => Black
)
Array (
[0] => Extra Small
[1] => Black
)
Array (
[0] => Large
[1] => White
)
Array (
[0] => Medium
[1] => White
)
Array (
[0] => Small
[1] => White
)
Array (
[0] => Extra Small
[1] => White
)
Array (
[0] =>
[1] =>
)
I would like something like
Array (
[0] => Size
[1] => Large
[2] => Medium
[3] => Small
[4] => Extra Small
[5] => Black
[6] => Black
etc....
)
could you push the data onto the $result
stack? e.g.
$result = array();
$result[] = $data[3];
$result[] = $data[4];
.. etc
精彩评论