function Clean_Array($array){
foreach ($array as $val) {
if (!empty($val) || !isset($val) || $val != '') {
$clean[] = $val;
}
}
return $clean;
}
function Paging($adjacents,$total_pages,$targetpage,$limit,$start,$page,$parameters)
{
/* Get data. */
/* Setup page vars for display. */
if ($page == 0) $page = 1; //if no page var is given, default to 1.
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
/*
Now we apply our rules and draw the pagination object.
We're actually saving the code to a variable in case we want to draw it more than once.
*/
$pagination = "";
if($lastpage > 1)
{
$pagination .= "
\n";
}
return $pagination;
}
function clean_compare ($str)
{
$str = str_replace("$"," ",$str);
$str = str_replace("#"," ",$str);
$str = str_replace("&"," ",$str);
$str = str_replace("*"," ",$str);
$str = str_replace("@"," ",$str);
$str = str_replace("^"," ",$str);
$str = str_replace("~"," ",$str);
$str = str_replace("َ","",$str);
$str = str_replace("ً","",$str);
$str = str_replace("ُ","",$str);
$str = str_replace("ٌ","",$str);
$str = str_replace("ِ","",$str);
$str = str_replace("ٍ","",$str);
$str = str_replace("ّ","",$str);
$str = str_replace("ْ","",$str);
$str = str_replace(" "," ",$str);
$str = str_replace(" "," ",$str);
$str = trim($str);
return ($str);
}
function htmlDiff($old, $new)
{
$ret = '';
$diff = diff(explode(' ', $old), explode(' ', $new));
foreach($diff as $k)
{
if(is_array($k))
{
$ret .= (!empty($k['d'])?"":''). (!empty($k['i'])?" ".implode(' ',$k['i'])." ":'');
}
else $ret .= $k . ' ';
}
return $ret;
}
function diff($old, $new)
{
$maxlen = 0;
foreach($old as $oindex => $ovalue)
{
$nkeys = array_keys($new, $ovalue);
foreach($nkeys as $nindex)
{
$matrix[$oindex][$nindex] = isset($matrix[$oindex - 1][$nindex - 1]) ? $matrix[$oindex - 1][$nindex - 1] + 1 : 1;
if($matrix[$oindex][$nindex] > $maxlen)
{
$maxlen = $matrix[$oindex][$nindex];
$omax = $oindex + 1 - $maxlen;
$nmax = $nindex + 1 - $maxlen;
}
}
}
if($maxlen == 0) return array(array('d'=>$old, 'i'=>$new));
return array_merge(
diff(array_slice($old, 0, $omax), array_slice($new, 0, $nmax)),
array_slice($new, $nmax, $maxlen),
diff(array_slice($old, $omax + $maxlen), array_slice($new, $nmax + $maxlen)));
}
function shadow ($incoming_word)
{
global $pieces;
foreach ($pieces as $k => $v)
$incoming_word = str_replace($v,"".$v."",$incoming_word);
echo $incoming_word;
}
?>
برنامج قارن - شبكة السنة النبوية وعلومها