Skip to content
Snippets Groups Projects
Select Git revision
  • main default protected
1 result

config.php

Blame
  • config.php 503 B
    <?php
    /**
     * @param string $index
     * @return string
     */
    function config(string $index) : string
    {
        $envPath = getcwd() . "/.env";
        if(file_exists($envPath)){
            $index = str_replace('_', '\\_', $index);
            $envFile = file_get_contents($envPath);
            preg_match("/" . $index . '=(.*?)\n/', $envFile, $matches);
            $value = $matches[count($matches) - 1];
            $value = preg_replace('/[^A-Za-z0-9\-]/', '', $value);
            return $value;
        } else {
            return "";
        }
    }