PHP Interview Questions In Hindi : PHP Interview Preparation
PHP com port communication In Hindi | Write on com port in PHP
PHP Program to check whether number is Palindrome or not | PHP Find Palindrome Number
PHP null In Hindi | PHP is null Function
Features of Laravel 9 : What is new in Laravel 9
Difference Between SOAP AND REST API In Node - Express In Hindi
Express.js helmet Example | Enhance Security In Node.JS App
What is Router in Networking? and How router Works?
session Storage In JavaScript In Hindi | JS session Storage In Hindi
If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
File : csv_import.html
<html>
<head>
<title>PHP Import CSV File</title>
</head>
<body>
<form action="./csv_import.php" method="POST" enctype=multipart/form-data>
<p><input type="file" name="myfile" multiple></p>
<p><button type="submit">Submit</button></p>
</form>
</body>
</html>
File : csv_import.php
<?php
// check if file is coming.
if(isset($_FILES['myfile']))
{
//first open file in READ mode.
if (($handle = fopen($_FILES['myfile']['tmp_name'], "r")) !== FALSE)
{
//here we will get every row as an array.
$csv_data = [];
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
$num = count($data);
if($num > 0)
{
// push row in an array.
$csv_data[] = $data;
}
}
// close file
fclose($handle);
// now print data.
echo "<pre>";
print_r($csv_data);
echo "</pre>";
}
else
{
echo "File is not readable";
}
}
?>
fopen() function का use file को open करने के लिए किया जाता है , example में file को r mode के साथ file को open किया गया है क्योंकि यहां हमें सिर्फ file को read करना है। आप अपनी need के according file को दुसरे mode में भी open कर सकते हैं।
fgetcsv() function का use open CSV file की line को read करने के लिए use किया जाता है। यह function csv file की single line को separator (by default ,
) और enclosure (by default "
) के bases पर array return करता है।
यह function open file pointer को close करता है।
Loading ...
Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)
Get connected with me. :) LinkedIn Twitter Instagram Facebook