Professional Web Applications Themes

Access an array from a text file??? - PHP Development

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_once("/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...

  1. #1

    Default 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_once("/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
    Nick Guest

  2. #2

    Default Re: Access an array from a text file???

    I <ce0d844c.0307131952.69612635posting.google.com >, Nick skrev:
    > 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_once("/arrays/stored_array_1.txt"));
    > [snip]
    I think you are looking for file() or serialize().

    mvrgr, Wouter

    --
    uws mail [email]uwsxs4all.nl[/email]

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

  3. #3

    Default 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
    Nick Guest

Similar Threads

  1. MySQL, SQL, Access and text file - Tutorial
    By pond scraper in forum Macromedia Dynamic HTML
    Replies: 0
    Last Post: September 28th, 03:46 PM
  2. Text File access in JDBC
    By visa25 in forum Coldfusion Database Access
    Replies: 1
    Last Post: March 23rd, 09:18 AM
  3. Problem with Access Database With Linked Text File
    By melody in forum ASP Database
    Replies: 8
    Last Post: October 9th, 06:54 AM
  4. Replies: 1
    Last Post: September 1st, 06:37 AM
  5. access to text file
    By ms shakeel in forum Microsoft Access
    Replies: 1
    Last Post: July 24th, 11:40 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139