Set multiple includes folders with arrays for set_include_path and ini_set using PHP
January 18, 2024
$set_include_path_array['/home/includes/test/a'] = 'Description of folder a';
$set_include_path_array['/home/includes/test/b'] = 'Description of folder b';
foreach($set_include_path_array as $set_include_path_k => $set_include_path_v){
$includes_path_loop .= PATH_SEPARATOR . $set_include_path_k;
}
$includes_path = '.' . $includes_path_loop;
set_include_path($includes_path);
or
ini_set('include_path', $includes_path);
include('a.php'); // in the a folder
include('b.php'); // in the b folder
include('c.php'); // in the current folder