mixed preg_filter ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )
Perform a regular expression search and replace
preg_filter() is identical to preg_replace() except it only returns the (possibly transformed) subjects where there was a match. For details about how this function works, read the preg_replace() documentation.
<?php
if (!function_exists('preg_filter')) {
function preg_filter($pattern, $replace, $subject, $limit = -1 , &$count = null) {
if(!is_array($subject)) {
$noArray = 1 ;
$subject = array($subject);
}
$preg = preg_replace($pattern, $replace, $subject, $limit, &$count);
$diff = array_diff($preg, $subject);
if($noArray == 1) $diff = implode($diff) ;
return $diff ;
}
}
?>
0 Comment:
Post a Comment