本文整理汇总了PHP中ArrayUtils::unsetIfKeyNumeric方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtils::unsetIfKeyNumeric方法的具体用法?PHP ArrayUtils::unsetIfKeyNumeric怎么用?PHP ArrayUtils::unsetIfKeyNumeric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayUtils
的用法示例。
在下文中一共展示了ArrayUtils::unsetIfKeyNumeric方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUnsetIfKeyNumeric
function testUnsetIfKeyNumeric()
{
$aValuesExpected = array(1 => 'aaaa', 2 => 'bbbb', 3 => 'cccc', 'x' => 'zzzz');
$aValues = $aValuesExpected;
ArrayUtils::unsetIfKeyNumeric($aValues, 'non-existent');
$this->assertEqual($aValuesExpected, $aValues);
ArrayUtils::unsetIfKeyNumeric($aValues, null);
$this->assertEqual($aValuesExpected, $aValues);
ArrayUtils::unsetIfKeyNumeric($aValues, 'zzzz');
$this->assertEqual($aValuesExpected, $aValues);
$aValuesExpected = array(1 => 'aaaa', 3 => 'cccc', 'x' => 'zzzz');
ArrayUtils::unsetIfKeyNumeric($aValues, 'bbbb');
$this->assertEqual($aValuesExpected, $aValues);
$aValuesExpected = array(1 => 'aaaa', 2 => 'bbbb', 'x' => 'zzzz');
$aValues = array(1 => 'aaaa', 2 => 'bbbb', 3 => null, 'x' => 'zzzz');
ArrayUtils::unsetIfKeyNumeric($aValues, null);
$this->assertEqual($aValuesExpected, $aValues);
}
示例2: getUniqueValuesFromColumn
/**
* Get array of unique values from this object table and it's $columnName
*
* @param string $columnName Column name to look for unique values inside
* @param string $exceptValue Usually we need a list of unique value except
* the one we already have
* @return array
* @access public
*/
function getUniqueValuesFromColumn($columnName, $exceptValue = null)
{
$fields = $this->table();
if (!array_key_exists($columnName, $fields)) {
DB_DataObject::raiseError("no such field '{$columnName}' exists in table '{$this->_tableName}'", DB_DATAOBJECT_ERROR_INVALIDARGS);
return array();
}
$this->selectAdd();
$this->selectAdd("DISTINCT {$columnName} AS {$columnName}");
$this->whereAdd($columnName . " <> ''");
$this->find();
$aValues = $this->getAll($columnName);
ArrayUtils::unsetIfKeyNumeric($aValues, $exceptValue);
return $aValues;
}
示例3: getUniqueUserNames
/**
* Gets a list of unique usernames.
*
* @static
* @param unknown_type $removeName
* @return array
*
* @TODO Remove this method once its use will be removed from UI
*/
public static function getUniqueUserNames($removeName = null)
{
$uniqueUsers = array();
$doUser = OA_Dal::factoryDO('users');
if (PEAR::isError($doUser)) {
return false;
}
$newUniqueNames = $doUser->getUniqueUsers();
$uniqueUsers = array_merge($uniqueUsers, $newUniqueNames);
ArrayUtils::unsetIfKeyNumeric($uniqueUsers, $removeName);
return $uniqueUsers;
}