title: parsing inline variables from string from file in php
body: <p>I'm localizing a website that I've built. I'm doing this by having a .lang file read and each line (syntax: key=string) is placed in a variable depending on the chosen language.</p>
  
  <p>This array is then used to place the strings in the correct places.</p>
  
  <p>The problem I'm having is that certain strings need to have hyperlinks in the middle of them for example someplace I've put my name that links to my contact page. Or a lot of the readouts of the website need to be in the strings.</p>
  
  <p>To solve this I've defined a variable that holds the html + Forecaster + html,
  and the localization file contains the $Forecaster variable in the string.</p>
  
  <p>The problem with this as I promptly discovered is that it stubbornly refuses to parse the inline variables in the strings from the file.</p>
  
  <p>Instead it prints the string and variable name as it looks in the file.</p>
  
  <p>And I have yet to find a way to make it parse the variables.</p>
  
  <p>For example "Heating up took $str_time" would be printed on the page exactly like that, instead of inputting the previously defined value of $str_time.</p>
  
  <p>I currently use fopen() and fgets() to open and read the lines. I then explode them to separate the key and the string and then place these into the array.</p>
  
  <p>Is there a way to make it parse the variables, or alternatively is there another way of reading the lines that allows for parsing the inline variables?</p>
  
  <p>The code that gets the line and converts it to the array looks like this:</p>
  
  <p>(It obviously loops through the lines)</p>
  
  <pre><code>#list($key, $string) = explode('=', $line);
  $key = strtok($line, '=');
  $string = strtok('=');
  $local[$key] = $string;
  $counter++;
  echo  $local[$key] . "&lt;br&gt;";
  </code></pre>
  
  <p>The counter is unused and the echo is for testing.</p>
  
  <p>A line from the .lang file looks like this:</p>
  
  <pre><code>fuel.results.heatup.timeused=Heating up took $str_time
  </code></pre>
  
  <p>I would call the array where I want the string like this:</p>
  
  <pre><code>$local['fuel.results.heatup.timeused']
  </code></pre>
  
  <p>As you can see I've tried both explode and strtok but it hasn't made a difference.</p>