Write to csv issue in php
up vote
0
down vote
favorite
I am reading the csv file and checking if image exist or not in my folder.
if not exist i am writing to another csv.
Used below code to do that.
<?php
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="missing_images.csv"');
$fp = fopen('php://output', 'w');
$row = 0;
$i =0;
if (($handle = fopen("images.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if($i >= 1){
$imgurl = $data[0];
$imgurl = trim($imgurl);
if($imgurl){
if (file_exists("import/".$imgurl)){
}else{
echo $imgurl;
fputcsv($fp, $imgurl);
} }
$row++;
}
$i++;
}
fclose($fp);
}
It is writing the missing images to same row and column. How to write to each row? Please anyone help me. Thanks
export-to-csv file-exists fputcsv
add a comment |
up vote
0
down vote
favorite
I am reading the csv file and checking if image exist or not in my folder.
if not exist i am writing to another csv.
Used below code to do that.
<?php
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="missing_images.csv"');
$fp = fopen('php://output', 'w');
$row = 0;
$i =0;
if (($handle = fopen("images.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if($i >= 1){
$imgurl = $data[0];
$imgurl = trim($imgurl);
if($imgurl){
if (file_exists("import/".$imgurl)){
}else{
echo $imgurl;
fputcsv($fp, $imgurl);
} }
$row++;
}
$i++;
}
fclose($fp);
}
It is writing the missing images to same row and column. How to write to each row? Please anyone help me. Thanks
export-to-csv file-exists fputcsv
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am reading the csv file and checking if image exist or not in my folder.
if not exist i am writing to another csv.
Used below code to do that.
<?php
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="missing_images.csv"');
$fp = fopen('php://output', 'w');
$row = 0;
$i =0;
if (($handle = fopen("images.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if($i >= 1){
$imgurl = $data[0];
$imgurl = trim($imgurl);
if($imgurl){
if (file_exists("import/".$imgurl)){
}else{
echo $imgurl;
fputcsv($fp, $imgurl);
} }
$row++;
}
$i++;
}
fclose($fp);
}
It is writing the missing images to same row and column. How to write to each row? Please anyone help me. Thanks
export-to-csv file-exists fputcsv
I am reading the csv file and checking if image exist or not in my folder.
if not exist i am writing to another csv.
Used below code to do that.
<?php
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="missing_images.csv"');
$fp = fopen('php://output', 'w');
$row = 0;
$i =0;
if (($handle = fopen("images.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if($i >= 1){
$imgurl = $data[0];
$imgurl = trim($imgurl);
if($imgurl){
if (file_exists("import/".$imgurl)){
}else{
echo $imgurl;
fputcsv($fp, $imgurl);
} }
$row++;
}
$i++;
}
fclose($fp);
}
It is writing the missing images to same row and column. How to write to each row? Please anyone help me. Thanks
export-to-csv file-exists fputcsv
export-to-csv file-exists fputcsv
edited yesterday
asked yesterday
jafar pinjar
1015
1015
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372401%2fwrite-to-csv-issue-in-php%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown