<?php
function loadEnv($path) {
    if (!file_exists($path)) {
        return false;
    }
    
    $lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    foreach ($lines as $line) {
        // Preskači komentare
        if (strpos(trim($line), '#') === 0) {
            continue;
        }
        
        list($name, $value) = explode('=', $line, 2);
        $name = trim($name);
        $value = trim($value);
        
        // Uklanjanje navodnika ako postoje
        if (preg_match('/^"(.+)"$/', $value, $matches)) {
            $value = $matches[1];
        }
        
        putenv("{$name}={$value}");
        $_ENV[$name] = $value;
    }
    
    return true;
}