Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Nuclear war can ruin your whole compile." -- Karl Lehenbauer


devel / comp.lang.php / Re: Issue with extracting values from the string (initially from a file) to insert in sql table

SubjectAuthor
o Re: Issue with extracting values from the string (initially from aHe

1
Re: Issue with extracting values from the string (initially from a file) to insert in sql table

<7758eddb-25af-44c7-b04d-3fd9802771aen@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=431&group=comp.lang.php#431

  copy link   Newsgroups: comp.lang.php
X-Received: by 2002:a05:622a:1102:: with SMTP id e2mr21795678qty.439.1643797413121;
Wed, 02 Feb 2022 02:23:33 -0800 (PST)
X-Received: by 2002:a25:cccb:: with SMTP id l194mr40442481ybf.752.1643797412761;
Wed, 02 Feb 2022 02:23:32 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.php
Date: Wed, 2 Feb 2022 02:23:32 -0800 (PST)
In-Reply-To: <941efc61-cbb4-4c80-bf33-6455bf9828a1@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=193.40.120.146; posting-account=HfIszAoAAAC8ch6q3uChpTWUALHCfEoF
NNTP-Posting-Host: 193.40.120.146
References: <941efc61-cbb4-4c80-bf33-6455bf9828a1@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7758eddb-25af-44c7-b04d-3fd9802771aen@googlegroups.com>
Subject: Re: Issue with extracting values from the string (initially from a
file) to insert in sql table
From: y12983@mail.ee (He)
Injection-Date: Wed, 02 Feb 2022 10:23:33 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 69
 by: He - Wed, 2 Feb 2022 10:23 UTC

Alla kirjutas LaupΓ€ev, 20. august 2016 kl 15:06:26 UTC+3:
> Hello!
>
> I will be grateful for your help on the issue of extracting values from a string, which I have obtained
> from a file.
>
> 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.
>
> Then i have tried to write a code to extract values from this file to be able to store them in a sql table.
> For now I am just testing the code by trying to extract only the first row from US.txt and get each
> variable, but I fail. var_dump() shows me that the whole string is stored at the key 0. I don't
> understand how to get each value separately.
>
> Please, take a look at this test code:
>
> <?php
>
> $file = "/home/ubuntu/workspace/US.txt";
>
> // perform tests on the file
> if(!file_exists($file))
> echo "Sorry, there is no such file $file\n";
> else if(!($open_file = fopen($file, "r")))
> echo "Sorry, couldn't open $file\n";
> else if(!is_readable($file))
> echo "$file is not readable\n";
> else if(filesize($file)==0)
> echo "Seems there is not content in the file $file\n";
> else
> {
> // store the first row of US.txt in a new variable
> $new_entry = fgetcsv($open_file, '\t');
> var_dump($new_entry);
>
> /******** var_dump result reveals all values of the first row stored as an array at key 0:
> array(1) {
> [0] =>
> string(48) "US 34034 APO AA Dillon 033 33.0364 -82.2493 1"
> }
> *********/
>
> //store each value in the string in a separate variable
> extract($new_entry);
>
> $entry1 = $new_entry[1]; // supposed to equal 'US'; it doesn't
> $entry2 = $new_entry[2]; // supposed to equal '34034'; it doesn't
> $entry3 = $new_entry[3]; // supposed to equal 'APO'; it doesn't
> $entry4 = $new_entry[4]; // supposed to equal 'AA'; it doesn't
> }
> ?>
>
> Thank you very much!

Hey

Where are you ?

πŸ™‚πŸ™‚πŸ™‚πŸ™‚πŸ™‚πŸ™‚πŸ™‚πŸ™‚πŸ™‚πŸ™‚πŸ™‚πŸ™‚πŸ™‚

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor