本文整理匯總了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;
}