PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
id decription manufactor price etc...
1243 keyboard microsoft 12,45$
5543 tft-lcd lg 220$
3245 mouse microsoft 4$
879 router asus 50$
In the other one i have
id thumpnail photo
2214 http://.... http://...
1243 http://.... http://....
5444 http://.... http://....
I want to put the column of thumpnail and photo at the end of the first cvs with base the right id.
Thanks a lota
Yes, i want to have in the first file all the information about one product.The problem is that there are not only same product in two files, because some products haw photos some others not. So i have to search the id of first file compare with second and if they are the same, add the two columns at the end of the first. The final result i want to be :
id decription, manufactor, price, thumpnail, photo
$reader1 = new Csv_Reader("./data/info.csv");
$reader2 = new Csv_Reader("./data/images.csv");
$writer = new Csv_Writer("./data/all.csv");
foreach ($reader1 as $info_row) {
foreach ($reader2 as $image_row) {
// key zero is the id, so compare
if ($info_row[0] == $images_row[0]) {
// make a copy of info row
$newrow = $info_row;
// add images to new row
$newrow[] = $image_row[1];
$newrow[] = $image_row[2];
// write data to new csv file
$writer->writeRow($newrow);
}
}
}
// write data to file
$writer->close();
First of all thank you for the quick reply.
I upload th folder "php-csv-utils-0.2" i go to the .../.../test/ and there is the below error
Warning: require_once(simpletest/unit_tester.php) [function.require-once]: failed to open stream: No such file or directory in /home/www/betinfo/aboutman.eu/www/php/php1/tests/index.php on line 47
Fatal error: require_once() [function.require]: Failed opening required 'simpletest/unit_tester.php' (include_path='.:/usr/local/share/pear:/home/www/betinfo/aboutman.eu/www/php-csv-utils-0.2/php-csv-utils') in /home/www/betinfo/aboutman.eu/www/php/php1/tests/index.php on line 47
Sorry if it something simple but i am beginner....
Because i want first of all to understand the philosophy to works with libraries. Would you like to tell me what i have to do. Except to write code i have to upload the folder of library and after to paly in folder test?