I'm not sure how to ask this but I am having a problem with output URL showing https//example.com
Below is my code, someone please i need assistance, I am trying to achieve https://example.com
while I got https//example.com
Am i missing anything on the regex or something..?
Thanks.
shuffle($randurl);
$smtp_email = $smtp_user;
$smtp_user = explode("@", $smtp_user) [0];
$randurls = array_shift($randurl);
preg_match('@^(?:https://)?([^/]+)@i', $randurls, $matches);
$host = $matches[1];
$host = explode('.', $host);
$host = $host[0];
$email64 = base64_encode($email);
$base64url = base64_decode($randurls);
if ($redirect == 1)
{
$randurls = "$randurls?email=" . urlencode($email64) . "";
}
else if ($redirect == 2)
{
$randurls = "$randurls?a=" . urlencode($email64) . "";
}
else if ($redirect == 3)
{
$randurls = "$randurls?email=" . urlencode($email) . "";
My Answer:
It looks like the issue might be with the regex pattern you are using in the preg_match function. The pattern you are using is looking for an optional "https://" at the beginning of the URL, but it seems like it is not capturing the colon and the double forward slash correctly.
You can try updating the regex pattern to include the colon and double forward slash like this:
php
preg_match('@^(?:https://)?([^/]+)@i', $randurls, $matches);
This should capture the "https://" part of the URL correctly and give you the desired output of "https://example.com" instead of "https//example.com".
Let me know if this helps or if you need any further assistance.
Rate this post
4 of 5 based on 8080 votesComments