• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP getCombinations函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getCombinations

function getCombinations($length, $prefix = null)
{
    $out = [];
    foreach ([1, 2, 3] as $value) {
        if ($length > 0) {
            $out = array_merge($out, getCombinations($length - 1, $prefix . $value));
        } else {
            $out[] = $prefix . $value;
        }
    }
    return $out;
}
开发者ID:catlabinteractive,项目名称:terra-triad-symbol-generator,代码行数:12,代码来源:index.php


示例2: getCombinations

/**
 * Function to get combinations of string from Array
 * @param <Array> $array
 * @param <String> $tempString
 * @return <Array>
 */
function getCombinations($array, $tempString = '')
{
    for ($i = 0; $i < count($array); $i++) {
        $splicedArray = $array;
        $element = array_splice($splicedArray, $i, 1);
        // removes and returns the i'th element
        if (count($splicedArray) > 0) {
            if (!is_array($result)) {
                $result = array();
            }
            $result = array_merge($result, getCombinations($splicedArray, $tempString . ' |##| ' . $element[0]));
        } else {
            return array($tempString . ' |##| ' . $element[0]);
        }
    }
    return $result;
}
开发者ID:yunter,项目名称:crm,代码行数:23,代码来源:utils.php


示例3: getConditionValue

 /**
  *
  * @param mixed $value
  * @param String $operator
  * @param WebserviceField $field
  */
 private function getConditionValue($value, $operator, $field)
 {
     $operator = strtolower($operator);
     $db = PearDatabase::getInstance();
     $inEqualityFieldTypes = ['currency', 'percentage', 'double', 'integer', 'number'];
     if (is_string($value) && $this->ignoreComma == false) {
         $commaSeparatedFieldTypes = array('picklist', 'multipicklist', 'owner', 'date', 'datetime', 'time', 'tree');
         if (in_array($field->getFieldDataType(), $commaSeparatedFieldTypes)) {
             $valueArray = explode(',', $value);
             if ($field->getFieldDataType() == 'multipicklist' && in_array($operator, array('e', 'n'))) {
                 $valueArray = getCombinations($valueArray);
                 foreach ($valueArray as $key => $value) {
                     $valueArray[$key] = ltrim($value, ' |##| ');
                 }
             }
         } else {
             $valueArray = array($value);
         }
     } elseif (is_array($value)) {
         $valueArray = $value;
     } else {
         $valueArray = array($value);
     }
     $sql = array();
     if ($operator == 'between' || $operator == 'bw' || $operator == 'notequal') {
         if ($field->getFieldName() == 'birthday') {
             $valueArray[0] = getValidDBInsertDateTimeValue($valueArray[0]);
             $valueArray[1] = getValidDBInsertDateTimeValue($valueArray[1]);
             $sql[] = "BETWEEN DATE_FORMAT(" . $db->quote($valueArray[0]) . ", '%m%d') AND " . "DATE_FORMAT(" . $db->quote($valueArray[1]) . ", '%m%d')";
         } else {
             if ($this->isDateType($field->getFieldDataType())) {
                 $start = explode(' ', $valueArray[0]);
                 $end = explode(' ', $valueArray[1]);
                 if ($operator == 'between' && count($start) == 2 && count($end) == 2) {
                     $valueArray[0] = getValidDBInsertDateTimeValue($start[0] . ' ' . $start[1]);
                     if ($start[0] == $end[0]) {
                         $dateTime = new DateTime($valueArray[0]);
                         $nextDay = $dateTime->modify('+1 days');
                         $nextDay = strtotime($nextDay->format('Y-m-d H:i:s')) - 1;
                         $nextDay = date('Y-m-d H:i:s', $nextDay);
                         $values = explode(' ', $nextDay);
                         $valueArray[1] = getValidDBInsertDateTimeValue($values[0]) . ' ' . $values[1];
                     } else {
                         $end = $valueArray[1];
                         $dateObject = new DateTimeField($end);
                         $valueArray[1] = $dateObject->getDBInsertDateTimeValue();
                     }
                 } else {
                     $valueArray[0] = getValidDBInsertDateTimeValue($valueArray[0]);
                     $dateTimeStart = explode(' ', $valueArray[0]);
                     if ($dateTimeStart[1] == '00:00:00' && $operator != 'between') {
                         $valueArray[0] = $dateTimeStart[0];
                     }
                     $valueArray[1] = getValidDBInsertDateTimeValue($valueArray[1]);
                     $dateTimeEnd = explode(' ', $valueArray[1]);
                     if ($dateTimeEnd[1] == '00:00:00' || $dateTimeEnd[1] == '23:59:59') {
                         $valueArray[1] = $dateTimeEnd[0];
                     }
                 }
             }
             if ($operator == 'notequal') {
                 $sql[] = "NOT BETWEEN " . $db->quote($valueArray[0]) . " AND " . $db->quote($valueArray[1]);
             } else {
                 $sql[] = "BETWEEN " . $db->quote($valueArray[0]) . " AND " . $db->quote($valueArray[1]);
             }
         }
         return $sql;
     }
     foreach ($valueArray as $value) {
         if (!$this->isStringType($field->getFieldDataType())) {
             $value = trim($value);
         }
         if ($operator == 'empty' || $operator == 'y') {
             $sql[] = sprintf("IS NULL OR %s = ''", $this->getSQLColumn($field->getFieldName()));
             continue;
         }
         if ($operator == 'ny') {
             $sql[] = sprintf("IS NOT NULL AND %s != ''", $this->getSQLColumn($field->getFieldName()));
             continue;
         }
         if (strtolower(trim($value)) == 'null' || trim($value) == '' && !$this->isStringType($field->getFieldDataType()) && ($operator == 'e' || $operator == 'n')) {
             if ($operator == 'e') {
                 $sql[] = "IS NULL";
                 continue;
             }
             $sql[] = "IS NOT NULL";
             continue;
         } elseif ($field->getFieldDataType() == 'boolean') {
             $value = strtolower($value);
             if ($value == 'yes') {
                 $value = 1;
             } elseif ($value == 'no') {
                 $value = 0;
             }
//.........这里部分代码省略.........
开发者ID:artisan4710,项目名称:YetiForceCRM,代码行数:101,代码来源:QueryGenerator.php


示例4: getConditionValue

 /**
  *
  * @param mixed $value
  * @param String $operator
  * @param WebserviceField $field
  */
 private function getConditionValue($value, $operator, $field)
 {
     $operator = strtolower($operator);
     $db = PearDatabase::getInstance();
     $inEqualityFieldTypes = ['currency', 'percentage', 'double', 'integer', 'number'];
     if (is_string($value) && $this->ignoreComma == false) {
         $commaSeparatedFieldTypes = ['picklist', 'multipicklist', 'owner', 'date', 'datetime', 'time', 'tree', 'sharedOwner', 'sharedOwner'];
         if (in_array($field->getFieldDataType(), $commaSeparatedFieldTypes)) {
             $valueArray = explode(',', $value);
             if ($field->getFieldDataType() == 'multipicklist' && in_array($operator, ['e', 'n'])) {
                 $valueArray = getCombinations($valueArray);
                 foreach ($valueArray as $key => $value) {
                     $valueArray[$key] = ltrim($value, ' |##| ');
                 }
             }
         } else {
             if ($field->getFieldDataType() == 'multiReferenceValue') {
                 $valueArray = explode(',', $value);
                 foreach ($valueArray as $key => $value) {
                     $valueArray[$key] = '|#|' . $value . '|#|';
                 }
             } else {
                 $valueArray = [$value];
             }
         }
     } elseif (is_array($value)) {
         $valueArray = $value;
     } else {
         $valueArray = [$value];
     }
     $sql = array();
     if ($operator == 'between' || $operator == 'bw' || $operator == 'notequal') {
         if ($field->getFieldName() == 'birthday') {
             $valueArray[0] = getValidDBInsertDateTimeValue($valueArray[0]);
             $valueArray[1] = getValidDBInsertDateTimeValue($valueArray[1]);
             $sql[] = "BETWEEN DATE_FORMAT(" . $db->quote($valueArray[0]) . ", '%m%d') AND " . "DATE_FORMAT(" . $db->quote($valueArray[1]) . ", '%m%d')";
         } else {
             if ($this->isDateType($field->getFieldDataType())) {
                 $start = explode(' ', $valueArray[0]);
                 $end = explode(' ', $valueArray[1]);
                 if ($operator == 'between' && count($start) == 2 && count($end) == 2) {
                     $valueArray[0] = getValidDBInsertDateTimeValue($start[0] . ' ' . $start[1]);
                     if ($start[0] == $end[0]) {
                         $dateTime = new DateTime($valueArray[0]);
                         $nextDay = $dateTime->modify('+1 days');
                         $nextDay = strtotime($nextDay->format('Y-m-d H:i:s')) - 1;
                         $nextDay = date('Y-m-d H:i:s', $nextDay);
                         $values = explode(' ', $nextDay);
                         $valueArray[1] = getValidDBInsertDateTimeValue($values[0]) . ' ' . $values[1];
                     } else {
                         $end = $valueArray[1];
                         $dateObject = new DateTimeField($end);
                         $valueArray[1] = $dateObject->getDBInsertDateTimeValue();
                     }
                 } else {
                     $valueArray[0] = getValidDBInsertDateTimeValue($valueArray[0]);
                     $dateTimeStart = explode(' ', $valueArray[0]);
                     if ($dateTimeStart[1] == '00:00:00' && $operator != 'between') {
                         $valueArray[0] = $dateTimeStart[0];
                     }
                     $valueArray[1] = getValidDBInsertDateTimeValue($valueArray[1]);
                     $dateTimeEnd = explode(' ', $valueArray[1]);
                     if ($dateTimeEnd[1] == '00:00:00' || $dateTimeEnd[1] == '23:59:59') {
                         $valueArray[1] = $dateTimeEnd[0];
                     }
                 }
             }
             if ($operator == 'notequal') {
                 $sql[] = "NOT BETWEEN " . $db->quote($valueArray[0]) . " AND " . $db->quote($valueArray[1]);
             } else {
                 $sql[] = "BETWEEN " . $db->quote($valueArray[0]) . " AND " . $db->quote($valueArray[1]);
             }
         }
         return $sql;
     }
     foreach ($valueArray as $value) {
         if (!$this->isStringType($field->getFieldDataType())) {
             $value = trim($value);
         }
         if ($operator == 'empty' || $operator == 'y') {
             $sql[] = sprintf("IS NULL OR %s = ''", $this->getSQLColumn($field->getFieldName()));
             continue;
         }
         if ($operator == 'ny') {
             $sql[] = sprintf("IS NOT NULL AND %s != ''", $this->getSQLColumn($field->getFieldName()));
             continue;
         }
         if (strtolower(trim($value)) == 'null' || trim($value) == '' && !$this->isStringType($field->getFieldDataType()) && ($operator == 'e' || $operator == 'n')) {
             if ($operator == 'e') {
                 $sql[] = "IS NULL";
                 continue;
             }
             $sql[] = "IS NOT NULL";
             continue;
//.........这里部分代码省略.........
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:101,代码来源:QueryGenerator.php


示例5: getConditionValue

 /**
  *
  * @param mixed $value
  * @param String $operator
  * @param WebserviceField $field
  */
 private function getConditionValue($value, $operator, $field)
 {
     $operator = strtolower($operator);
     $db = PearDatabase::getInstance();
     if (is_string($value) && $this->ignoreComma == false) {
         $valueArray = explode(',', $value);
         if ($field->getFieldDataType() == 'multipicklist' && in_array($operator, array('e', 'n'))) {
             $valueArray = getCombinations($valueArray);
             foreach ($valueArray as $key => $value) {
                 $valueArray[$key] = ltrim($value, ' |##| ');
             }
         }
     } elseif (is_array($value)) {
         $valueArray = $value;
     } else {
         $valueArray = array($value);
     }
     $sql = array();
     if ($operator == 'between' || $operator == 'bw' || $operator == 'notequal') {
         if ($field->getFieldName() == 'birthday') {
             $valueArray[0] = getValidDBInsertDateTimeValue($valueArray[0]);
             $valueArray[1] = getValidDBInsertDateTimeValue($valueArray[1]);
             $sql[] = "BETWEEN DATE_FORMAT(" . $db->quote($valueArray[0]) . ", '%m%d') AND " . "DATE_FORMAT(" . $db->quote($valueArray[1]) . ", '%m%d')";
         } else {
             if ($this->isDateType($field->getFieldDataType())) {
                 $valueArray[0] = getValidDBInsertDateTimeValue($valueArray[0]);
                 $dateTimeStart = explode(' ', $valueArray[0]);
                 if ($dateTimeStart[1] == '00:00:00' && $operator != 'between') {
                     $valueArray[0] = $dateTimeStart[0];
                 }
                 $valueArray[1] = getValidDBInsertDateTimeValue($valueArray[1]);
                 $dateTimeEnd = explode(' ', $valueArray[1]);
                 if ($dateTimeEnd[1] == '00:00:00') {
                     $valueArray[1] = $dateTimeEnd[0];
                 }
             }
             if ($operator == 'notequal') {
                 $sql[] = "NOT BETWEEN " . $db->quote($valueArray[0]) . " AND " . $db->quote($valueArray[1]);
             } else {
                 $sql[] = "BETWEEN " . $db->quote($valueArray[0]) . " AND " . $db->quote($valueArray[1]);
             }
         }
         return $sql;
     }
     foreach ($valueArray as $value) {
         if (!$this->isStringType($field->getFieldDataType())) {
             $value = trim($value);
         }
         if ($operator == 'empty' || $operator == 'y') {
             $sql[] = sprintf("IS NULL OR %s = ''", $this->getSQLColumn($field->getFieldName()));
             continue;
         }
         if (strtolower(trim($value)) == 'null' || trim($value) == '' && !$this->isStringType($field->getFieldDataType()) && ($operator == 'e' || $operator == 'n')) {
             if ($operator == 'e') {
                 $sql[] = "IS NULL";
                 continue;
             }
             $sql[] = "IS NOT NULL";
             continue;
         } elseif ($field->getFieldDataType() == 'boolean') {
             $value = strtolower($value);
             if ($value == 'yes') {
                 $value = 1;
             } elseif ($value == 'no') {
                 $value = 0;
             }
         } elseif ($this->isDateType($field->getFieldDataType())) {
             $value = getValidDBInsertDateTimeValue($value);
             $dateTime = explode(' ', $value);
             if ($dateTime[1] == '00:00:00') {
                 $value = $dateTime[0];
             }
         }
         if ($field->getFieldName() == 'birthday' && !$this->isRelativeSearchOperators($operator)) {
             $value = "DATE_FORMAT(" . $db->quote($value) . ", '%m%d')";
         } else {
             $value = $db->sql_escape_string($value);
         }
         if (trim($value) == '' && ($operator == 's' || $operator == 'ew' || $operator == 'c') && ($this->isStringType($field->getFieldDataType()) || $field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) {
             $sql[] = "LIKE ''";
             continue;
         }
         if (trim($value) == '' && $operator == 'k' && $this->isStringType($field->getFieldDataType())) {
             $sql[] = "NOT LIKE ''";
             continue;
         }
         switch ($operator) {
             case 'e':
                 $sqlOperator = "=";
                 break;
             case 'n':
                 $sqlOperator = "<>";
                 break;
             case 's':
//.........这里部分代码省略.........
开发者ID:nouphet,项目名称:vtigercrm-6.0.0-ja,代码行数:101,代码来源:QueryGenerator.php


示例6: getCombinations

function getCombinations($in, &$res, $current)
{
    $out = $in;
    array_shift($out);
    // get the next section
    $section = array_values($in)[0];
    foreach ($section as $variation) {
        $tmp = $current . ' ' . $variation->id;
        if (count($in) == 1) {
            // this is the last section
            array_push($res, reorderCombinations($tmp));
        } else {
            getCombinations($out, $res, $tmp);
        }
    }
}
开发者ID:sublyro,项目名称:optimizely-canvas-disable-MVT-combination,代码行数:16,代码来源:canvas-content.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP getComboArray函数代码示例发布时间:2022-05-15
下一篇:
PHP getColumnVisibilityPermission函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap