当前位置: 首页>>代码示例>>PHP>>正文


PHP compare函数代码示例

本文整理汇总了PHP中compare函数的典型用法代码示例。如果您正苦于以下问题:PHP compare函数的具体用法?PHP compare怎么用?PHP compare使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了compare函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: compare

 function compare($dir, $racine)
 {
     $retour = 'terminée avec succès.<br>';
     $files = array_diff(scandir($dir), array('.', '..'));
     foreach ($files as $file) {
         if (is_dir($dir . $file)) {
             if (file_exists($racine . $file)) {
                 compare($dir . $file . '/', $racine . $file . '/');
             } else {
                 mkdir($racine . $file);
             }
         } else {
             if (file_exists($racine . $file)) {
                 $shaNow = sha1_file($racine . $file);
                 $shaNext = sha1_file($dir . $file);
                 if ($shaNow != $shaNext) {
                     if (filemtime($dir . $file) >= filemtime($racine . $file)) {
                         $retour .= $racine . $file . ' Le fichier actuel a une date de modification plus récente<br>';
                     } else {
                         transfertFile($dir . '/' . $file, $racine . $file);
                     }
                 }
             } else {
                 transfertFile($dir . '/' . $file, $racine . $file);
             }
         }
     }
     return $retour;
 }
开发者ID:akwawa,项目名称:RipMeal-v2,代码行数:29,代码来源:miseAJour.php

示例2: validate

function validate($email, $pw)
{
	require 'connect.php';
	$q="select userid, password from user where emailid='$email'";
	$r=mysql_query($q);
	if(!$r)
		header("Location:error.html");
	else
		{
			$row=mysql_fetch_row($r);
			$resusid=$row[0];
			$respw=$row[1];
			$flag=compare($respw, $pw);
		}
	if($flag)
		{
			//user is authenticated
			authenticate($resusid);
		}
	else
		{
			header("Location:error.html");
		}
	 
}
开发者ID:rashmibachani,项目名称:Feed-Reader,代码行数:25,代码来源:funx.php

示例3: cond

/**
 * Adds if statement logic to change output based on if statement.
 * 
 * 
 * @param mixed &$parsed
 * @return void
 */
function cond(&$parsed)
{
    global $cssp, $browser;
    foreach ($parsed as $block => $css) {
        foreach ($parsed[$block] as $selector => $styles) {
            foreach ($styles as $property => $values) {
                if (strpos($values[0], 'cond(') !== false) {
                    /**
                     * Clean up variable names and Formatting.
                     */
                    $condition = get_string_between($values[0], "cond(", ")");
                    $ifParams = explode("?", $condition);
                    $ifResults = explode(":", $ifParams[1]);
                    $ifCond = explode(" ", $ifParams[0]);
                    $ifCond[0] = interp($ifCond[0]);
                    //Convert PHP string to Values
                    $ifCond[2] = interp($ifCond[2]);
                    //Convert PHP string to Values
                    $test = compare($ifCond[0], $ifCond[1], $ifCond[2]);
                    $parsed[$block][$selector][$property] = '';
                    //Remove existing Cond Statement
                    if ($test) {
                        $parsed[$block][$selector][$property][] = $ifResults[0];
                        //Place True Value
                    } else {
                        $parsed[$block][$selector][$property][] = $ifResults[1];
                        //Place False Value
                    }
                }
            }
        }
    }
}
开发者ID:KealJones,项目名称:ConditionLogic-TurbineCSS-Plugin,代码行数:40,代码来源:cond.php

示例4: create_graph

function create_graph($a, $b)
{
    // 2. matching
    $count = 0;
    $gml = "graph [\ncomment \"Matching\"\ndirected 1\n# First set of labels\n";
    foreach ($a as $str) {
        $gml .= "node [ id {$count} label \"" . addcslashes($str, '"') . "\" ]\n";
        $count++;
    }
    $gml .= "# Second set of labels\n";
    foreach ($b as $str) {
        $gml .= "node [ id {$count} label \"" . addcslashes($str, '"') . "\" ]\n";
        $count++;
    }
    $m = count($a);
    $n = count($b);
    for ($i = 0; $i < $m; $i++) {
        for ($j = 0; $j < $n; $j++) {
            $gml .= "edge [ source {$i} target " . ($m + $j) . " label \"" . floor(100 * compare($a[$i], $b[$j])) . "\" ]\n";
        }
    }
    $gml .= "]\n";
    /*
    echo '<pre>';
    echo $gml;
    echo '</pre>';
    */
    return $gml;
}
开发者ID:rdmpage,项目名称:phyloinformatics,代码行数:29,代码来源:index.php

示例5: u_spearmanRanks

 protected function u_spearmanRanks(\SplFixedArray $_data, $_size, $_stride, $_offset, \SplFixedArray $_ranks, &$_combinations)
 {
     $_combinations = 0;
     /* Using native arrays because native functions are faster than written */
     $temp1 = $temp2 = array_fill(0, $_size, 0.0);
     for ($i = 0; $i < $_size; $i++) {
         $temp1[$i] = $_data[$i * $_stride + $_offset];
         $temp2[$i] = $i;
     }
     array_multisort($temp1, $temp2);
     for ($i = 0; $i < $_size; $i++) {
         $count = 0;
         while ($i < $_size - 1) {
             if (compare($temp1[$i], $temp1[$i + 1])) {
                 break;
             }
             $count++;
             $i++;
         }
         $value = $i;
         if ($count > 0) {
             $value -= $count / 2.0;
             $_combinations += $count * ($count + 1) * ($count + 2);
         }
         while ($count >= 0) {
             $temp1[$i - $count] = $temp2[$i - $count];
             $temp2[$i - $count] = $value;
             $count--;
         }
     }
     array_multisort($temp1, $temp2);
     for ($i = 0; $i < $_size; $i++) {
         $_ranks[$i] = $temp2[$i];
     }
 }
开发者ID:altgamer,项目名称:portfolio,代码行数:35,代码来源:Compound.php

示例6: ucompare

 /**
  * usort() compatible comparision function (i.e., returns -1 | 0 | +1).
  */
 public static function ucompare($a, $b)
 {
     $result = compare($a, $b);
     if ($result == 0) {
         return 0;
     }
     if ($result > 0) {
         return 1;
     }
     return -1;
 }
开发者ID:laszloekovacs,项目名称:Doomsday-Engine,代码行数:14,代码来源:version.class.php

示例7: compare

function compare($arg1, $arg2)
{
    //echo "compare is called <br>";
    global $_;
    //if obj1 and obj2 are objects then continue below after conditional block
    if (!(is_object($arg1) and is_object($arg2))) {
        //if obj1 and obj2 are arrays then check that array counts match
        if (is_array($arg1) and is_array($arg2)) {
            //check if the two arrays have a matching count
            if (count($arg1) != count($arg2)) {
                return false;
            } else {
                //continue with this else when $arg1 and $arg2 are arrays
                foreach ($arg1 as $key => $value) {
                    //for each $key in $arg1
                    //check if the $key value is an object or an array
                    if (is_object($arg1[$key]) or is_array($arg1[$key])) {
                        //if the $key value is an object or an array run
                        //compare on the object key values
                        //if the compare returns false return false
                        if (!compare($arg1[$key], $arg2[$key])) {
                            return false;
                        }
                    } elseif ($arg1[$key] != $arg2[$key]) {
                        return false;
                    }
                }
            }
        } else {
            return $arg1 == $arg2;
        }
    } else {
        //continue with this else when both $arg1 and $arg2 are objects
        foreach ($arg1 as $key => $value) {
            //for each $key in $arg1
            //check if the $key value is an object or an array
            if (is_object($arg1->{$key}) or is_array($arg1->{$key})) {
                //if the $key value is an object or an array run
                //compare on the object key values
                //if the compare returns false return false
                if (!compare($arg1->{$key}, $arg2->{$key})) {
                    return false;
                }
            } elseif ($arg1->{$key} != $arg2->{$key}) {
                return false;
            }
        }
    }
    return true;
}
开发者ID:louisbuchbinder,项目名称:myUnderscorePHP,代码行数:50,代码来源:utilities.php

示例8: combine_arrays

function combine_arrays($array1, $array2)
{
    $sameArray = compare($array1, $array2);
    $newArray = array();
    foreach ($array2 as $key => $items) {
        if (!is_null($array1[$key])) {
            array_push($newArray, $array1[$key]);
        }
        foreach ($sameArray as $index) {
            if ($index == $key) {
                continue 2;
            }
        }
        array_push($newArray, $items);
    }
    return $newArray;
}
开发者ID:wbreiding,项目名称:Codeup_Exercises,代码行数:17,代码来源:merge-arrays.php

示例9: neither

/** 
Finds a random index in the array such that neither (index-1) nor (index)
contains an element equal to $element
*/
function findSuitableIndex($array, $element, $arraySize)
{
    $index = rand(0, $arraySize - 1);
    for ($i = 0; $i < $arraySize - 1; $i++) {
        if (!compare($array[$index], $element)) {
            if ($index == 0 || !compare($array[$index - 1], $element)) {
                return $index;
            } else {
                if ($index == $arraySize - 1) {
                    return $arraySize;
                }
            }
        }
        $index = ($index + 1) % $arraySize;
    }
    die('An error occurred (5), please try again.<br>If this problem persists, contact a webmaster at: <a href="mailto:shs@altervista.org">shs@altervista.org</a>');
}
开发者ID:RaffaeleCanale,项目名称:Lying-Cues-Experience,代码行数:21,代码来源:survey_header.php

示例10: array_sort

function array_sort(&$array, $sort_key)
{
    $size = count($array);
    sort($array);
    foreach ($array as $key => $val) {
        if ($key + 1 == $size) {
            return;
        }
        while (compare($array[$key], $array[$key + 1], $sort_key) == -1) {
            $tmp = $array[$key + 1];
            $array[$key + 1] = $array[$key];
            $array[$key] = $tmp;
            if ($key != 0) {
                $key--;
            }
        }
    }
}
开发者ID:PiratenparteiHessen,项目名称:wikiarguments,代码行数:18,代码来源:functions.php

示例11: compare

function compare($a_aRow1, $a_aRow2, $a_lField = 0)
{
    global $g_aaSortArray;
    $lCompareVal = 0;
    if ($a_lField < count($g_aaSortArray)) {
        $sSortFieldName = $g_aaSortArray[$a_lField]['name'];
        $sSortFieldDir = $g_aaSortArray[$a_lField]['dir'];
        $vValue1 = eval('return $a_aRow1[' . $sSortFieldName . '];');
        $vValue2 = eval('return $a_aRow2[' . $sSortFieldName . '];');
        if ($vValue1 == $vValue2) {
            $lCompareVal = compare($a_aRow1, $a_aRow2, $a_lField + 1);
        } else {
            $lCompareVal = strtolower($vValue1) > strtolower($vValue2) ? 1 : -1;
            if (strtolower(substr($sSortFieldDir, 0, 4)) == 'desc') {
                $lCompareVal = -$lCompareVal;
            }
        }
    }
    return $lCompareVal;
}
开发者ID:Evolix,项目名称:lilac,代码行数:20,代码来源:sitedb-utility.php

示例12: Nav_data

function Nav_data($dbc, $path_info)
{
    $q = "SELECT * FROM pages";
    $r = mysqli_query($dbc, $q);
    while ($nav = mysqli_fetch_assoc($r)) {
        ?>
		
			
<li <?php 
        compare($path_info['call_parts'][0], $nav['nav'], 'class = "active"');
        ?>
> <a href="<?php 
        echo $nav['nav'];
        ?>
"><?php 
        echo $nav['nav'];
        ?>
</a></li>	

<?php 
    }
}
开发者ID:kodaholic,项目名称:testphp,代码行数:22,代码来源:mainNav.php

示例13: exec_help

        $node->addChild($key, (string) $value)->addAttribute("tool", "kdu");
    }
    if ($format[0] == "DJVU" || $format[0] == "DJVU (multi-page)" || $format[0] == "jhove DJVU") {
        $djvu_dump = exec_help("djvudump '{$file}'", "djvudump '{$file}'");
        $node = $xml->addChild("djvu_dump", htmlentities($djvu_dump));
    }
    return $xml;
}
$files = $_GET['file'];
$op = $_GET['op'];
$action = $_GET['action'];
if ((count($files) == 2 || count($files) == 1) && ($action == "compare" || $action == "execute" || $action == "EXECUTE")) {
    if (count($files) == 2) {
        $xml = compare($files[0], $files[1]);
    } else {
        $xml = compare($files[0], "null");
    }
    $smarty = smarty_init();
    if ($xml == false || $xml->{"error"}) {
        $smarty->assign("error", $xml == false ? "Error processing image" : $xml->{"error"});
        $smarty->assign('template', 'error.tpl');
        $smarty->assign('selected', 'compare');
        $smarty->display('layout.tpl');
        exit(1);
    }
    $images = array();
    $count = 0;
    foreach (count($files) == 2 ? array("image1", "image2") : array("image1") as $image) {
        $data = array();
        $data["thumbnail"] = "images/" . $xml->{$image}->{"checksum"} . ".png";
        $data["big"] = "images/" . $xml->{$image}->{"checksum"} . "_big.png";
开发者ID:grevutiu-gabriel,项目名称:differ,代码行数:31,代码来源:compare.php

示例14: foreach

foreach ($dictionary as $rel => $rel_def) {
    if (!empty($rel_def['indices'])) {
        $indices = $rel_def['indices'];
    } else {
        $indices = array();
    }
    //clean vardef defintions.. removed indexes not value for this dbtype.
    //set index name as the key.
    $var_indices = array();
    foreach ($indices as $definition) {
        if (empty($definition['db']) or $definition['db'] == $focus->db->dbType) {
            $var_indices[$definition['name']] = $definition;
        }
    }
    $db_indices = $focus->db->helper->get_indices($rel_def['table']);
    compare($rel_def['table'], $db_indices, $var_indices);
}
////	END PROCESS RELATIONSHIP METADATA
///////////////////////////////////////////////////////////////////////////////
function_exists('logThis') ? logThis("RepairIndex: we have " . count($drop_index) . " indices to DROP.") : "";
function_exists('logThis') ? logThis("RepairIndex: we have " . count($add_index) . " indices to ADD.") : "";
function_exists('logThis') ? logThis("RepairIndex: we have " . count($change_index) . " indices to CHANGE.") : "";
if (count($drop_index) > 0 or count($add_index) > 0 or count($change_index) > 0) {
    if (!isset($_REQUEST['mode']) or $_REQUEST['mode'] != 'execute') {
        echo $_REQUEST['silent'] ? "" : "<BR><BR><BR>";
        echo $_REQUEST['silent'] ? "" : "<a href='index.php?module=Administration&action=RepairIndex&mode=execute'>Execute Script</a>";
    }
    $focus = new Account();
    if (count($drop_index) > 0) {
        if (isset($_REQUEST['mode']) and $_REQUEST['mode'] == 'execute') {
            echo $_REQUEST['silent'] ? "" : $mod_strings['LBL_REPAIR_INDEX_DROPPING'];
开发者ID:sysraj86,项目名称:carnivalcrm,代码行数:31,代码来源:RepairIndex.php

示例15: query

echo <<<_END
<span class='formheading'><p>Enter the details of your workout below:
</p></span>
<form method='POST' action='add.php'>
<span class='nonulfield'>The torture lasted</span>
<input type='text' name='min' size='4' maxlength='5'/>
<span class='nonulfield'>minutes.<br>
<br><span class='nonulfield'>I wasted my time with </span>
<select name='activity'>
_END;
$result = query("SELECT * FROM exercises");
for ($i = 0; $i < $result->num_rows; $i++) {
    $row = $result->fetch_array(MYSQLI_ASSOC);
    $exercise_name = $row['name'];
    echo "<option value='{$exercise_name}'>{$exercise_name}</option>";
}
echo "</select><span class='nonulfield'>. (" . "<a href='newtype.php'>Add Exercise Type</a>)<br><br>";
if (!isset($_SESSION['weight'])) {
    echo "<span class='nonulfield'>On a good day, I weigh </span>\n    <input type='text' name='weight' size='4' maxlength='5' value='{$weight}'/>\n    <span class='nonulfield'> pounds.</span>";
}
?>
<br><br>
<input type='submit' value='Submit'/>
<br>
</form>
</body>
</html>
<?php 
if ($calories) {
    compare($calories);
}
开发者ID:kennethsinder,项目名称:workout-buddy,代码行数:31,代码来源:add.php


注:本文中的compare函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。