Access an array from a text file???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nick

    Access an array from a text file???

    Im trying to build an array from elements I have stored in a text file
    (So I can access them on multiple pages). What is the syntax for this?
    I thought it might be...

    storedArray1 = array(require_o nce("/arrays/stored_array_1. txt"));

    or

    storedArray1 = array(include("/arrays/stored_array_1. txt"));

    but I guess you can only use the 'include' statement when inserting
    text into html code NOT php code? TIA -Nick
  • uws

    #2
    Re: Access an array from a text file???

    I <ce0d844c.03071 31952.69612635@ posting.google. com>, Nick skrev:[color=blue]
    > Im trying to build an array from elements I have stored in a text file
    > (So I can access them on multiple pages). What is the syntax for this?
    > I thought it might be...
    >
    > storedArray1 = array(require_o nce("/arrays/stored_array_1. txt"));
    > [snip][/color]

    I think you are looking for file() or serialize().

    mvrgr, Wouter

    --
    uws mail uws@xs4all.nl

    i will hold you close :: if you're afraid of heights -- incubus

    Comment

    • Nick

      #3
      Re: Access an array from a text file???

      Thank you all for responding. I tried the 'file()' funtion which I
      guess returns an array (each line of text is an element of the array).
      Thats exactly what I needed! However, the array elements do not get
      read literally. For example, if I use an if statement...

      if (storedArray1[0] == 'some text') echo storedArray1[0];

      It only works if the 'some text' string does not have spaces. Any
      suggestions??? Thanx -Nick

      Comment

      Working...