Advertisement
GAMELASTER

Simple PHP language getter

Apr 19th, 2018
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 KB | None | 0 0
  1. <?php
  2.  
  3. $lang = [
  4.   "whistik" => [
  5.     "je" => [
  6.       "profik" => "Nie",
  7.       "lamka" => "Ano"
  8.     ]
  9.   ]
  10. ];
  11.  
  12. function getLanguageNode($path)
  13. {
  14.   global $lang;
  15.   $levels = explode(">", $path);
  16.   $latestNode = $lang;
  17.   for ($level = 0; $level < count($levels); $level++) {
  18.     if (isset($latestNode[$levels[$level]])) {
  19.       $latestNode = $latestNode[$levels[$level]];
  20.     } else {
  21.       return false;
  22.     }
  23.   }
  24.   return $latestNode;
  25. }
  26.  
  27. echo getLanguageNode("whistik>je>lamka");
  28.  
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement