本文整理汇总了PHP中ArrayUtil::inArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtil::inArray方法的具体用法?PHP ArrayUtil::inArray怎么用?PHP ArrayUtil::inArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayUtil
的用法示例。
在下文中一共展示了ArrayUtil::inArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: optionsFromObjects
public static function optionsFromObjects($aObjects, $sKeyMethod = null, $sValueMethod = null, $mSelected = null, $aCustomOptions = array('' => '------'), $bStrict = false)
{
$aResult = array();
if (!is_array($mSelected)) {
if ($mSelected === null) {
$mSelected = array();
} else {
$mSelected = array($mSelected);
}
}
$aSelected = array();
foreach ($aObjects as $oObject) {
$sKey = null;
$sValue = null;
if ($sKeyMethod === null) {
$sKey = Util::idForObject($oObject);
} else {
$sKey = $oObject->{$sKeyMethod}();
}
if ($sValueMethod === null) {
$sValue = Util::nameForObject($oObject);
} else {
$sValue = $oObject->{$sValueMethod}();
}
$aResult[$sKey] = $sValue;
if (ArrayUtil::inArray($oObject, $mSelected, true, $sKeyMethod)) {
//Always strict
$aSelected[] = $sKey;
}
}
if (is_array($aCustomOptions)) {
foreach ($aCustomOptions as $sCustomKey => $sCustomValue) {
if (ArrayUtil::inArray($sCustomKey, $mSelected, $bStrict)) {
$aSelected[] = $sCustomKey;
}
}
}
return self::optionsFromArray($aResult, $aSelected, '_', $aCustomOptions, $bStrict);
}
示例2: getBackendUsersOther
/**
* @deprecated use query methods
*/
public static function getBackendUsersOther($sSearch = null, $iUserId = null, $bCountOnly = false)
{
$oCriteria = new Criteria();
$oCriteria->add(self::IS_ADMIN, false);
$aBackendUsers = self::getBackendUsers($sSearch, $iUserId, $bCountOnly, $oCriteria);
$aBackendUsersWithRights = self::getBackendUsersWithRights($sSearch, $iUserId, $bCountOnly);
if ($bCountOnly) {
return $aBackendUsers - $aBackendUsersWithRights > 0;
}
foreach ($aBackendUsersWithRights as $i => $oBackendUser) {
if (ArrayUtil::inArray($oBackendUser, $aBackendUsers)) {
unset($aBackendUsers[$i]);
}
}
return $aBackendUsers;
}