Path: csiph.com!weretis.net!feeder4.news.weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: "Christoph M. Becker" Newsgroups: comp.lang.php Subject: Re: Issue with extracting values from the string (initially from a file) to insert in sql table Date: Sat, 20 Aug 2016 14:55:46 +0200 Organization: solani.org Lines: 17 Message-ID: References: <941efc61-cbb4-4c80-bf33-6455bf9828a1@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: solani.org 1471697725 13615 eJwNyMEBwCAIA8CVVEgo46iE/Uew9zwYJ284QUejj7QG5lmsK7/SKFMqEUT0v9WGCu5PsVP2ADMhEdc= (20 Aug 2016 12:55:25 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sat, 20 Aug 2016 12:55:25 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 In-Reply-To: <941efc61-cbb4-4c80-bf33-6455bf9828a1@googlegroups.com> X-NNTP-Posting-Host: eJwNwoERwCAIBLCVEPhHxwGR/UdoL4Fx8YYTdMzv2ANmKyQXpa3mxnjFaLYKD7e/kmQqW9M+FMgQ+Q== Cancel-Lock: sha1:SokadMtEprLcdsXgFNFtZLpMDko= X-User-ID: eJwFwQUBwEAMBDBLpSvI+RX8S1gCdfYOc7jhcAnTia/dkneiIykhyMd6WU22VqxSK/uah34JHhB9 Xref: csiph.com comp.lang.php:16946 On 20.08.2016 at 14:06, Alla wrote: > I have stored a file US.txt in my home directory from http://download.geonames.org/export/zip/readme.txt > Here is the quote from the exercise I am doing: "US.txt is quite like a CSV file except that fields > are delimited with \t (a tab character) instead of a comma. " Hence, I am using fgetcsv() function. > > // store the first row of US.txt in a new variable > $new_entry = fgetcsv($open_file, '\t'); $delimiter is the *third* parameter of fgetcsv, not the _second_. Also heed Rudy's advice, that the tab character must be double-quoted. So: $new_entry = fgetcsv($open_file, 0, "\t"); -- Christoph M. Becker