Small Php scripts which makes a developers life easier

How to Generate unique GUID For a particular user in php ?
function gen_uuid() {
    return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
        // 32 bits for "time_low"
        mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),

        // 16 bits for "time_mid"
        mt_rand( 0, 0xffff ),

        // 16 bits for "time_hi_and_version",
        // four most significant bits holds version number 4
        mt_rand( 0, 0x0fff ) | 0x4000,

        // 16 bits, 8 bits for "clk_seq_hi_res",
        // 8 bits for "clk_seq_low",
        // two most significant bits holds zero and one for variant DCE1.1
        mt_rand( 0, 0x3fff ) | 0x8000,

        // 48 bits for "node"
        mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
how to remove , from last characters of a string in php?
rtrim("hello world,",",")
how to read body text from a post request in php ?
$response = json_decode(file_get_contents('php://input'));
how to connect with postgresql in php ?
$credentials = "user =xxxx password=xxxx";
pg_connect( "$host $port $dbname $credentials");
//Please make sure to enable the pg_sql in php.ini file.
//For enabling pg_sql in php.ini, please remove the semi column(;) before the module you want to enable. Then restart the web server and it will solve the issue.
how to send POST request from php ?
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"postvar1=value1&postvar2=value2&postvar3=value3");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
curl_close ($ch);
if ($server_output == "OK") {echo "OK";} else { echo "FAIL"; }

The above scripts have been written by ibnus dedicated developers who are trying their best to bring out the great possible outcome out of the code base.