Jump to content

FL-RKS

New Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by FL-RKS

  1. i refeer to the variables stored in a .env file in the root of your proyect, like: DB_HOST="localhost" DB_USER="root" DB_NAME="test" DB_PASSWORD="123abs" API_KEY="secret_key" there is a superglobal variavle called $_ENV, but is empty even if the .env file is valid
  2. i need a way to charge get enviroment variables stored in a .env file i know that there are libraries to do that, but is takes a lot of time, there is a native way to do that in php in less time?
  3. idk if you can store arrays in a database, but if you cant use this <?php if(isset($_POST['domains']) && !empty($_POST['domains'])){ $domains = explode("\n",$_POST['domains']); $validDomains = array(); foreach($domains as $domain){ if(preg_match(/*regrex expresion*/, $domain)){ $validDomain = strtolower($domain); $validDomain = str_replace("www." , "" , $validDomain); $validDomain = str_replace(" " , "" , $validDomain); array_push($validDomains, $validDomain); } else { continue; } } // new code $domainString = implode(',', $validDomains); //store it in a databse } ?> if you want to convert the string to a array, use this: <?php // example $domainsString = obtainDomainsFromDatabase() $domainsArray = explode(',', $domainsString) // use $domainsArray ?>
  4. <?php // checks if the request exists and isnt empty if(isset($_POST['domains']) && !empty($_POST['domains'])){ // using explode you can also put how mainy domains you want, like, explode("\n",$_POST['domains'], 3), you can change 3 for other numer but // put the number of domains is optional $domains = explode("\n",$_POST['domains']); $validDomains = array(); // check id there are valid domain foreach($domains as $domain){ if(preg_match(/*some regerex expresion to check if element is a valid domain*/, $domain)){ $validDomain = strtolower($domain); $validDomain = str_replace("www." , "" , $validDomain); $validDomain = str_replace(" " , "" , $validDomain); array_push($validDomains, $validDomain) } else { // handle error, like a error message // or continue with the loop without put the domain in $validDomains continue } } // do something with $domains, that is a array // redirect to other page or something } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.