0

whats good and simply way to convert csv file to 2d array, where i will be able to get value with

$rownumber=1;
$columnnumber=1;
foreach ($array['rows'] as $row) {
  foreach ($row as $value) {
    print($array[$rownumber][$columnnumber]);
  }
  print('<br>');
}

I've tried

$f = $_FILES["file"]['tmp_name'];
//move_uploaded_file($_FILES['file']['tmp_name'],'tmp/'.$_FILES['file']['name']);
$csvData=file_get_contents($_FILES['file']['tmp_name']);
$array['rows']=explode("\n",$csvData);
foreach ($array['rows'] as $value) {
  $array['rows']['values'] = explode(';',$value);
}

But i cant get exact column from row im currently on.

3
  • so you want to declare an array per row? seems a bit.. inefficient Commented Aug 29, 2019 at 10:26
  • stackoverflow.com/a/5593885/6556397 Commented Aug 29, 2019 at 10:29
  • pastebin.com/xK9t4QXa edited code, it works, but does it look fine? Commented Aug 29, 2019 at 10:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.