title: PHP Change and save value of a variable without DB
body: <p>I have a little programm for a forum that looks into a thread and saves the date of each users' last post into a MySQL database. So far, so good, no problem with that. But if I want to change the thread the program looks into, I of course have to open the php-file and change the threadid-number manually. Here's a code-snippet of how it's like now:</p>
  
  <pre><code>// change this variable if you want to use another thread
  $thread = 452;  
  
  // save last post of each user into db
  $result = $db-&gt;query("SELECT userid, MAX(posttime) AS maxpost 
                  FROM bb$n_posts WHERE threadid = '$thread'
                  GROUP BY userid ORDER BY userid");
  </code></pre>
  
  <p>I want to share my programm with users that have no clue about php, so I want to make it more user-friendly and use a GUI for that. I would implement a select-box with all available threads, the user chooses one and via submitting the id will be set. Again this would be absolutely easy if I would just use MySQL for that, but that would be kind of a waste. I would have to create a new table with just this one variable in my database and I would like to avoid that.</p>
  
  <p>Is there a way to change the variable directly in the file and save it? Like, get this variable from this file, replace value with this and save file. I tried thinking about using fwrite and the like for it, I just don't know how to get one specific variable from a file.</p>