Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: fgetc or fread

  1. #1
    nst
    nst is offline
    New Coder
    Join Date
    Jul 2005
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    fgetc or fread

    Hi everyone,

    I 'm trying to build a small app that should read data from a stock exchange text file. These look like the following

    AAAP 04/02/2005 8.92 - 100 8.92 8.92 892.00 1 8.92
    ABAX 04/02/2005 4.82 - 31839 4.84 4.74 153253.68 84 4.80
    Do you suggest to use fgetc and read every single character after another or fread and take whole strings.
    I think of using a sort of
    Code:
    while($one_char!="\n")
    in order to read the next line. Does that seem OK to you?

    Thanks.

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Depends on how you need the data or variables.

    You could use http://uk.php.net/function.file-get-contents

  • #3
    nst
    nst is offline
    New Coder
    Join Date
    Jul 2005
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I read:
    file_get_contents -- Reads entire file into a string
    I don't think that is what I am looking for.

    What I need is to put some data in an array and then to a mysql table, therefore I need variables.

    For instance: symbol_name($i), which will be put into a field named stock_name.
    In the above example we should get
    symbol_name(0) = AAAP
    symbol_name(1) = ABAX
    and so on.

    Similar applies to $price($), etc.
    Last edited by nst; 02-13-2006 at 04:08 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •