Skip to content

Instantly share code, notes, and snippets.

@sahanh
Created April 27, 2019 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sahanh/7a28e9757edfe7e9fb14a1d383f9c3dd to your computer and use it in GitHub Desktop.
Save sahanh/7a28e9757edfe7e9fb14a1d383f9c3dd to your computer and use it in GitHub Desktop.
Formatting phone number url for calendly
<?php
/**
* sahan@devquickie.com
*/
$inputs = (array) $_GET;
$clPath = isset($_GET["calendly"]) ? $_GET["calendly"] : null;
$phoneField = isset($_GET["phone"]) ? $_GET["phone"] : null;
$final = [];
foreach ($inputs as $inputField => $input) {
if ($phoneField == $inputField) {
$final[$inputField] = str_replace("+", "", trim($input));
} else {
$final[$inputField] = $input;
}
}
$query = http_build_query($final);
header("Location: https://calendly.com/{$clPath}?{$query}");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment