I need to read an .xls
file and put it into an array. I'm using laravel-excel package for reading excel files.
I have a Excel file like this :
I need to have an array like this :
[
'9921234567' => 'First Text',
'9929876544' => 'Second Text',
'9927654321' => 'Third Text',
'9928765432' => 'Fourth Text',
]
What I have tried so far :
Excel::load('sample.xls', function($reader) {
$reader->dd();
});
Problem:
The problem is it reads the first row as column!
0 => RowCollection {#619
#title: "Sheet1"
#items: array:3 [
0 => CellCollection {#623
#title: null
#items: array:2 [
9921234567 => 9929876544.0
"first_text" => "Second Text"
]
}
1 => CellCollection {#624
#title: null
#items: array:2 [
9921234567 => 9927654321.0
"first_text" => "Third Text"
]
}
2 => CellCollection {#625
#title: null
#items: array:2 [
9921234567 => 9928765432.0
"first_text" => "Fourth Text"
]
}
]
}
Look, I don't want to first row values count as column name!
Any helps would be great appreciated.
via Hamed Kamrava