Results 1 to 2 of 2

Thread: CSV string lines

  1. #1

    Thread Starter
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    CSV string lines

    Hi, I have been asked to organise this CSV file (http://intranet.pool.cornwall.sch.uk/weather/now.csv) using php. It logs the weather every 7 seconds aparently but it logs it like this:
    Code:
    1,2,3,4,5
    1,2,3,4,5
    how can i get it to output like this?
    Code:
    1: 1
    2: 2
    I have been stuck on this for like an hour now and dont know which function to use.
    Thanks, dandono
    If there is only one perfect person in the universe, does that make them imperfect?

  2. #2

    Thread Starter
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    Re: CSV string lines

    I figured out i could just explode it so i did and got it working.
    PHP Code:
    <?php
    $path
    ="http://intranet.pool.cornwall.sch.uk/weather/now.csv";
    $contents=stream_get_contents(fopen($path,"r"));
    $thing=explode(",",$contents);
    $val1=trim($thing[26],"PRNOW ");
    $val2=trim($thing[26],$val1);
    ?>
    $val1 & $val2 are done like that because there is no commas between line 1 and line 2 and i can't change it.
    If there is only one perfect person in the universe, does that make them imperfect?

Posting Permissions

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



Click Here to Expand Forum to Full Width