This snippet makes prettier json output:
header('Content-Type: application/json');
$json_pretty = json_encode(json_decode($response), JSON_PRETTY_PRINT);
echo '<pre>' . $json_pretty . '</pre>';
This snippet searches a block of text or json for URLs. Used in cURL script to get a customer invoice link from a big json response.
extractPmtUrl($response);
function extractPmtUrl($response){
$string=$response; preg_match('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $string, $match);
$invoiceLink=$match[0];
echo '<div><p class="text-center lead text-success">Invoice sent!</p><div>';
$custArray['invoiceLink'] =$invoiceLink;
$_SESSION['custArray'] =$custArray;
return$invoiceLink;
}