Skip to content

Instantly share code, notes, and snippets.

@lelotnk
Created February 4, 2013 19:16
Show Gist options
  • Save lelotnk/4708841 to your computer and use it in GitHub Desktop.
Save lelotnk/4708841 to your computer and use it in GitHub Desktop.
Função para mascarar uma string.
<?php
function maskstr($mask, $string)
{
$string = str_replace(' ', '', $string);
for ($i = 0; $i < strlen($string); $i++) {
$mask[strpos($mask, '#')] = $string[$i];
}
return $mask;
}
echo maskstr('(##) ####-####', '0000000000');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment