#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    22
    Rep Power
    0
    Hi again,***Thanks to Shiju Rajan Problem fixed
    Had form passing variables - OK; added following
    <? if (!$fp = fopen("MyFile.txt","w")) {
    print ("unable to open file"); } else {
    for ($i = 0; $i < 9; $i++) { fputs($fp,$MyArray[$i]);} }
    fclose($fp); ?>
    This saves the array as 1 long line. How would I extract and reassemble array?
    Also after adding above have following error from ISP
    "Zero Sized Reply"
    Any/All help would be appreciated.

    ------------------
    With my kind regards,
    Peter.

    [This message has been edited by pjlewis (edited July 02, 2000).]
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    Peter,

    ----------------
    i had given you an answer in the morning related to the same topic.But i don't know where it is disappeared.i think some one has deleted that message..
    ----------------


    <? if (!$fp = fopen("MyFile.txt","w")) {
    print ("unable to open file"); } else {
    for ($i = 0; $i < 9; $i++) { fputs($fp,$MyArray[$i]);} }
    fclose($fp); ?>


    just change your logic a bit for writing this array to your file.

    <?

    $MyArray=array("1","2","3","4","5","6","7","8","9");

    $values=implode(",",$MyArray);

    // just seperate your values with a comma or a pipe sign("|") before writing to the file.
    //That would make your work more easy when you read the value from the file(ie,reassebling the array).

    $fp=fopen("MyFile.txt","w");
    fputs($fp,$values);
    fclose($fp);

    ?>

    The above code will write values in the file like 1,2,3,4,5...

    so now you should read the values from this file.

    <?
    $fd = fopen("MyFile.txt", "r");
    $content = fread($fd, filesize("MyFile.txt"));
    fclose($fd);

    $reassembled_array=expolde(",",$content);
    //reasseble your array here.remove all the ","'s.

    ?>


    Good Luck!!!





    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."

Similar Threads

  1. C program to read from a data file into an array
    By rathornton in forum C Programming
    Replies: 4
    Last Post: March 16th, 2004, 12:23 PM
  2. Pointer problem in opening a file
    By LAKI in forum C Programming
    Replies: 13
    Last Post: February 11th, 2004, 09:27 AM
  3. .raw file into 2d array
    By rorybreen1 in forum C Programming
    Replies: 2
    Last Post: January 30th, 2004, 12:02 PM
  4. C++ programming help.
    By Programming1 in forum C Programming
    Replies: 1
    Last Post: January 20th, 2004, 11:47 AM
  5. creating an array and writing it to a csv file
    By bounty5 in forum Visual Basic Programming
    Replies: 7
    Last Post: January 19th, 2004, 08:42 PM

IMN logo majestic logo threadwatch logo seochat tools logo