I am reading data from csv file and combining the array.i have below header in csv
First Name,Last Name,Email,Contact No
And i am giving below data in csv in respect of column
Usertest,name,[email protected],645383638
then using array_combine() to combine the data.in this case its working fine and giving me below result
Array
(
[First Name] => test
[Last Name] => name
[Email] => [email protected]
[Contact No] => 74647454
)
But if i am leaving contact number blank in csv then array_combine() is not working giving me empty array()
Array
(
)
$dataKeys = First Name,Last Name,Email,Contact No;
$dataValues = Usertest,name,[email protected]
$dataArr = array_combine(str_getcsv($dataKeys), str_getcsv($dataValues));
Because the number of parameter is not same in csv header and data field in row.so am not getting how to fix this.
Warning: array_combine(): Both parameters should have an equal number of elementsarray_combine()when the number of provided keys does not match the number of values is documented: " ThrowsE_WARNINGif the number of elements inkeysandvaluesdoes not match."array_pad()to fill the values array with''(ornull) to the required length.