[wd_asp elements=’search’ ratio=’100%’ id=1]

Trim & Replace UK numbers – Php

21st November 2013

Php - Strings

php codehaven
Remove Spaces


$string = str_replace(' ','',$string);

";

if (strlen($string) > 11)
{

if (substr($string, 0, 4) === '0044')
{
echo '';
$string = substr_replace($string, '0', 0, 4);
}

if (substr($string, 0, 2) === '00')
{
echo '';
$string = substr_replace($string, '0', 0, 2);
}
if (substr($string, 0, 2) === '44')
{
echo '';
$string = substr_replace($string, '0', 0, 2);
}
// $main = strlen($string);
echo "END NUMBER = ".$string;
}

else
{
if (substr($string, 0, 2) === '44')
{
echo '';
$string = substr_replace($string, '0', 0, 2);
}
echo $string;

}
?>