Answer the question
In order to leave comments, you need to log in
How to merge php lines into one?
Good day! Essence of a question: I am engaged in parsing of excel of the table, with the subsequent entering of the data from it into MySQL. I am using the phpexcel library. There is a table of the form
I get data from it and the database is entered like this:
I need to combine data from several lines so that they are in one line, something like this:
Ie . you need to either combine using PHP or MYSQL (it didn’t work via CONCAT :( ) or something else.
Any ideas how this can be implemented?
Answer the question
In order to leave comments, you need to log in
Get data, compare, and shove the last line into the array to the same record (current), then join it and forward to the database.
See, after parsing we have an array
objects$table_excel.
$arr_new = [];
$A = 0;
foreach($table_excel as &$row){
if($row->A){
$A = $row->A;
$arr_new[$A] = &$row;
}else{
$arr_new[$A]['F'] .= ",$row->F";
}
}
//$arr_new - Массив который теперь можно заносить в базу, где группировка сделанная по полю F
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question