Skip to content

Instantly share code, notes, and snippets.

@the7th
Created June 5, 2018 15:19
Show Gist options
  • Select an option

  • Save the7th/776430818ccffb1cdf0a0d959f7141cf to your computer and use it in GitHub Desktop.

Select an option

Save the7th/776430818ccffb1cdf0a0d959f7141cf to your computer and use it in GitHub Desktop.
Sanitize phone number for Malaysia
<?php
$prepare_phone_num = $phone_num;
$phone = $prepare_phone_num;
$phone = str_replace(["-", "–", " ", "+"], '', $phone);
if ("0" == substr($phone, 0, 1))
{
$phone = "6" . $phone;
}
if ("60" != substr($phone, 0, 2))
{
$phone = "60" . $phone;
}
return $phone;
@iqmal852
Copy link

iqmal852 commented Jun 6, 2018

mastaa tajulll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment