Welcome Guest, Not a member yet? Register   Sign In
load a lang file into an array
#2

(This post was last modified: 04-04-2017, 01:24 AM by muuucho.)

Workaround:

open the lang file
    $string = file_get_contents($file);
  $lang_file_rows = array();
  $lang_file_rows = preg_split("/\\r\\n|\\r|\\n/", $string);


Loop through the array of rows and check if the row begins with $lang....
if so you explode each of this lines with "=" and save it into another array like $lang_file_variables
But before that you need to trim the key and the value as follows:


Run a rtrim on the key element, then remove the frist 7 ( $lang[' ) and the last two charaters ( '] )
Then run a ltrim on the value element, them remove the first character ( ' )  and the two last ( '; )

Now you have created an array from a lang file.



Reply


Messages In This Thread
load a lang file into an array - by muuucho - 03-28-2017, 09:24 AM
RE: load a lang file into an array - by muuucho - 04-04-2017, 01:21 AM
RE: load a lang file into an array - by muuucho - 04-04-2017, 09:11 AM
RE: load a lang file into an array - by muuucho - 04-06-2017, 05:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB