Skip to content

Instantly share code, notes, and snippets.

@jancimajek
Last active August 29, 2015 14:16
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 jancimajek/1d39929d9212fb366b7a to your computer and use it in GitHub Desktop.
Save jancimajek/1d39929d9212fb366b7a to your computer and use it in GitHub Desktop.
Test of preg_match replacement
<?php
t(
array(
'www.notft.com',
'ft.com',
'.ft.com',
'x.ft.com.au',
'x.ft.com',
),
function ($t)
{
return preg_match('/^(.+)\.ft\.com$/', $t);
},
function ($t)
{
return (substr($t, -7) === '.ft.com') && strlen($t) > 7;
}
);
function t($ta, $o, $n)
{
foreach ($ta as $t) {
printf(
'OLD:%d -- NEW:%d -- %s' . PHP_EOL,
$o($t),
$n($t),
$t
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment