function my_preg_match($run = null, $params = null)
{
preg_match($run, $params, $result);
if (isset($result[1])) {
$result = trim($result[1]);
return $result;
}
}
function my_preg_match($run = null, $params = null, $i = 0)
{
preg_match($run, $params, $result);
if (!empty($result[0])) {
return $result[$i];
}
else {
echo 'Вхождений не найдено';
}
}
my_preg_match('/(\d)(\d)/','12'); // result 12
my_preg_match('/(\d)(\d)/','12', 1); // result 1
my_preg_match('/(\d)(\d)/','12', 2); // result 2