Skip to content

Instantly share code, notes, and snippets.

@niravmadariya
Created November 10, 2018 18:05
Show Gist options
  • Save niravmadariya/87e2a3c540401e3ef02a821a0f1face2 to your computer and use it in GitHub Desktop.
Save niravmadariya/87e2a3c540401e3ef02a821a0f1face2 to your computer and use it in GitHub Desktop.
MySQL-in-app connection File
<?php
$conn = getenv("MYSQLCONNSTR_localdb"); // this will return the whole connectionstring in a single string
$conarr2 = explode(";",$conn); // Let's beautify it, by splitting it and decorating it in an array
$conarr = array();
foreach($conarr2 as $key=>$value){
$k = substr($value,0,strpos($value,'='));
$conarr[$k] = substr($value,strpos($value,'=')+1);
}
print_r($conarr); // $conarr is an array of values of connection string
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment