Find Jobs
Hire Freelancers

300371 Text file to array

N/A

Completed
Posted over 20 years ago

N/A

Paid on delivery
Text file to array Script for re-sale. I'd like to read a text file into an array so that I have the values available for placing into an HTML file. There are a few other requirements to help with error checking, documentation, and layout, but it's pretty straightforward. Please note that my PHP below may contain syntax errors, and you may be able to offer a better use of PHP syntax. EXAMPLE ----------------------------------------------- This is an example text data file The first valid line has field names Other valid lines have data Code|Name|Description|Options|Cost Dresses DR1-5|Dress with straps|Very nice|Red,Blue,Green|10.00 DR1-6|Dress without straps|Even nicer|Red,Blue|9.00 DR3-3|Dress with long bits|Awsome number|Black only|20.00 Tops Top-2|Red Sweater|Looks great|Red,Blue|£12.00 Top-2a|Red Sweater (large)|Looks greater|Red,Blue|14.00 ----------------------------------------------- And produces an array, for example, $products such that: echo $products(0,'Code') // Displays 'Code' echo $products(0,'Description') // Displays 'Descripton' echo $products(1,'Code') // Displays 'DR1-5' echo $products(1,'Name') // Displays 'Dress with straps' echo $products(1,'Options') // Displays 'Red,Blue,Green' // Can we do this?... echo $products(1,'Options',1) // Displays 'Red' echo $products(1,'Options',2) // Displays 'Blue' echo $products(1,'Options',3) // Displays 'Green' // How about this?... echo $products(DR1-5,'Options',1) // Displays 'Red' FEATURES 1. Read an ASCII text file with specified configurable delimiters respresenting records and fields. Eg. \n for end of line (end of record), and | for end of field. 2. The first valid records contains field names, subsequent valid names contain data. 3. To be documented, organised into functions, and include configuration options at the beginning (eg. record a field delimiters). 4. To optionally handled Comma Separated Values, eg. "DR1-5","Dress with straps","Very nice","Red,Blue,Green","10.00" Note that the field separated may appear within the quotes! 5. The resulting array will ignore lines (ie remove invalid records) that do not have a complete record, and place the invalid lines into another array. Optionally displaying this array will allow a designer to quickly see whether the original text file is formatted correctly. 6. Functons that demonstrates working data and code: .. a. A function to display the field names, eg.: .. .. .. Code | Name | Description | Options | Cost .. b. A function to display the contents of a specifed record, eg.: .. .. .. DR1-5 | Dress with straps | Very nice | Red,Blue,Green | 10.00 .. c. Display the contents of all records where Title includes the text "Dress", eg: .. .. .. DR1-5 | Dress with straps | Very nice | Red,Blue,Green | $10.00 .. .. .. DR1-6 | Dress without straps | Even nicer | Red,Blue | $9.00 .. .. .. DR3-3 | Dress with long bits | Awsome number | Black only | $20.00 Regards, Ian
Project ID: 2046433

About the project

1 proposal
Remote project
Active 12 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
$40 USD in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED KINGDOM
Sandbach, United Kingdom
5.0
10
Payment method verified
Member since Apr 30, 2003

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.