I have 2 files. first find.php
he has a script
<?php
require("config/connect_bd.php"); // create a connection to the database
$query = "SELECT * FROM `translate` WHERE 1"; //Looking for a translation by ID
$result = mysqli_query($con, $query);
$word = array();
foreach($result as $row){ // Loop through the result
$word[]= ['key'=>$row['id'],'ru'=>$row['ru'],'en'=>$row['en'],'kz'=> $row['kz']];
}
$site_lang = $_GET['lang'];
if(is_null($site_lang)){
$site_lang = 'ru';
}
function lang_base($lang,$id_base){
for($i=0;$i<count($word);$i++){
if($word[$i]['key'] == $id_base){
echo $word[$i][$lang];
break;
}
}
}
?>
The second script main.php calls the lang_base function
<?php
require_once("find.php"); // подключем перевод
lang_base('ru','123');
?>
But it doesn't see the variable (array) $word What to do?
Tried changing require to require_once and vice versa.
Put in lang_base global $word
Still can't see...