'; $vars = func_get_args(); foreach ($vars as $var) { echo '
'; if (is_scalar($var) || is_null($var)) { var_dump($var); } else { print_r($var); } echo ''; } echo '
'; print_r($backtrace); echo ''; $html = ob_get_contents(); ob_end_clean(); echo $html; exit(); } function csv2array($file) { $row = 1; $result = array(); if (($handle = fopen($file, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if ($row != 1) { $result[] = array('id' => $data[0], 'name' => $data[1]); } $row++; } fclose($handle); } return $result; } $a = csv2array('01-clients.csv'); $clientSql = 'INSERT INTO `cf_Client` (`id`, `number`, `name`, `added`, `changed`) VALUES' . "\n"; foreach($a as $row) { $clientSql .= '(' . $row['id'] . ', "' . $row['id'] . '", "' . $row['name'] . '", NULL, NULL),' . "\n"; } $clientSql = substr($clientSql, 0, -2) . ';'; $file = "importClient.sql"; $handle = fopen($file, 'w'); fwrite($handle, $clientSql); fclose($handle); echo ('File "' . $file . '" has been created'); ?>