Previous Thread
Next Thread
Print Thread
Rate Thread
#101224 09/20/2000 11:00 PM
Joined: Sep 2000
Posts: 5
Junior Member
Junior Member
Offline
Joined: Sep 2000
Posts: 5
Ok.. here's the situation:

I need to read in data to a file, each line of the file has two parts, lets say A and B. After i read the data into a structure, i need to search the structure for A, and then find the value of B.

Now, in this case which would be more efficiant? a hash or an array? I'm reasonably sure a hash would be more efficiant for access, but I'm not sure how to read the data into the Hash from a file, assigning A to the key and B to the value.

Or would it just be more efficiant to loop through the file directly?

------------------
Programming today is a race between software engineers striving to
build bigger and better idiot- proof programs, and the Universe trying
to produce bigger and better idiots. So far, the Universe is winning.

Sponsored Links
#101225 09/21/2000 12:09 AM
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
P.I.T.A. / Programmer
Offline
Joined: Sep 2000
Posts: 755
If you are looking for two pieces to be related to each other, then a hash is the way to go. An array is essentially a single, sequential list.

Assuming 1 set of data per line, pipe deliminated:

Code
code:

--mark

[This message has been edited by Mark Badolato (edited September 21, 2000).]


"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
badfrog
badfrog
somewhere on the coast of Maine
Posts: 94
Joined: March 2007
Forum Statistics
Forums63
Topics37,575
Posts293,931
Members13,824
Most Online6,139
Sep 21st, 2024
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,834
Greg Hard 4,625
Top Posters(30 Days)
Gizmo 1
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2025 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.1
(Snapshot build 20240918)