title: PHP variable from array to function
body: <pre><code>&lt;?
  $dir4 = "report/";
  $dh4  = opendir($dir4);
  $giCity = geoip_open("geoip/GeoLiteCity.dat", GEOIP_STANDARD);
  while (false !== ($filename4 = readdir($dh4))) {
      $files4[] = $filename4;
      sort($files4);
  }
  for ($p = 2; $p &lt; count($files4); ++$p){
      ${"name" . $p} = pathinfo($files4[$p], PATHINFO_FILENAME);
      ${"idset" . $p} = substr("${"name" . $p}", 7, strpos("${"name" . $p} ", '-'));
      ${"soubor" . $p} = fopen("report/$files4[$p]", "r");
      ${"ipset" . $p}=fgets(${"soubor" . $p});
      ${"ipset2" . $p} = substr("${"ipset" . $p}", strpos("${"ipset" . $p}", ','));
      ${"ipset" . $p}= str_replace("${"ipset2" . $p}", "", "${"ipset" . $p}");
      ${"stav" . $p}=fgets(${"soubor" . $p});
      ${"ver" . $p}=fgets(${"soubor" . $p});
      ${"group" . $p}=fgets(${"soubor" . $p});
      ${"ipl" . $p}=fgets(${"soubor" . $p});
      ${"hw" . $p}=fgets(${"soubor" . $p});
      ${"stavh" . $p} = substr("${"stav" . $p}", 0, strpos("${"stav" . $p}", '['));
      ${"stav" . $p}= str_replace("${"stavh" . $p}", "", "${"stav" . $p}");
      fclose(${"soubor" . $p});
      //MAP loading START
  
      ${"record" . $p} = geoip_record_by_addr($giCity, ${"group" . $p});
      ${"lat" . $p} = ${"record" . $p}-&gt;latitude;
      ${"long" . $p} = ${"record" . $p}-&gt;longitude;
  
  
      ${"relace" . $p} = fopen("map.dat", "a");
      ${"text1" . $p} = '&lt;script&gt;';
      ${"text2" . $p} ='var showPosition = function (position) {';
      ${"text3" . $p} = 'var userLatLng = new google.maps.LatLng('."${"lat" . $p}".','."${"long" . $p}".');';
      ${"text4" . $p} = ' var marker = new google.maps.Marker({ position: userLatLng,title: \'BOT\',map: map });} ';
      ${"text5" . $p} = 'navigator.geolocation.getCurrentPosition(showPosition); &lt;/script&gt;';
      fwrite(${"relace" . $p},"\n${"text1" . $p}");
      fwrite(${"relace" . $p},"\n${"text2" . $p}");
      fwrite(${"relace" . $p},"\n${"text3" . $p}");
      fwrite(${"relace" . $p},"\n${"text4" . $p}");
      fwrite(${"relace" . $p},"\n${"text5" . $p}");
      fclose(${"relace" . $p});
      ?&gt;
  </code></pre>
  
  <p>This Code works only if variable is static <code>${"group" . $p}-&gt;$group="xxxxxxx";</code> but when is reading by for it will sucessfully echo but will not work with that function <code>${"group" . $p}</code> function is acting like nothing in that variable.function dont want accept array as string and this not too group[$p] but is not empty ,i dont know why function is accepting only variables like $group = "54.112.55.111"; in array is same but its not working</p>