本文整理汇总了PHP中ArrayUtil::arrayUniqueRecursive方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtil::arrayUniqueRecursive方法的具体用法?PHP ArrayUtil::arrayUniqueRecursive怎么用?PHP ArrayUtil::arrayUniqueRecursive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayUtil
的用法示例。
在下文中一共展示了ArrayUtil::arrayUniqueRecursive方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testArrayUniqueRecursive
public function testArrayUniqueRecursive()
{
$array = array('testValue1', 'testValue2', 'testValue3');
$expected = array('testValue1', 'testValue2', 'testValue3');
$this->assertEquals($expected, ArrayUtil::arrayUniqueRecursive($array));
$array = array('testValue1', 'testValue2', 'testValue2');
$expected = array('testValue1', 'testValue2');
$this->assertEquals($expected, ArrayUtil::arrayUniqueRecursive($array));
$array = array('testValue1', 'testValue1', 'testValue1');
$expected = array('testValue1');
$this->assertEquals($expected, ArrayUtil::arrayUniqueRecursive($array));
$array = array(array('testKey1' => 'testValue1', 'testKey2' => 'testValue2', 'testKey3' => 'textValue3'));
$expected = array(array('testKey1' => 'testValue1', 'testKey2' => 'testValue2', 'testKey3' => 'textValue3'));
$this->assertEquals($expected, ArrayUtil::arrayUniqueRecursive($array));
$array = array(array('testKey1' => 'testValue1', 'testKey2' => 'testValue1', 'testKey3' => 'textValue3'));
$expected = array(array('testKey1' => 'testValue1', 'testKey3' => 'textValue3'));
$this->assertEquals($expected, ArrayUtil::arrayUniqueRecursive($array));
}
示例2: resolveEmailRecipientsFromEmailMessage
/**
* Get recipient details from email message.
* Have to cover two cases: when message is CC-ed or BCC-ed to dropbox,
* and when email message is forwarded to dropbox.
* 1. If message is CC-ed or BCC-ed to dropbox, recipients can be exctracted from "To" field of email message
* 2. If message is forwarded, then email from which message is forwarded to dropbox is recipient
* @param ImapMessage $emailMessage
* @param array $emailRecipient
*/
public static function resolveEmailRecipientsFromEmailMessage(ImapMessage $emailMessage)
{
// Check if email is forwarded or not.
if (self::isMessageForwarded($emailMessage)) {
// Somebody sent email to Zurmo user, the user forwarded it to dropbox, so the user is a recipient
$emailRecipients = array(array('email' => $emailMessage->fromEmail, 'name' => $emailMessage->fromName, 'type' => EmailMessageRecipient::TYPE_TO));
} else {
$emailRecipients = array();
// Zurmo user sent email, so recipients are in 'To' and 'CC' fields
if (!empty($emailMessage->to)) {
foreach ($emailMessage->to as $key => $value) {
$emailMessage->to[$key]['type'] = EmailMessageRecipient::TYPE_TO;
if ($value['email'] == Yii::app()->imap->imapUsername) {
unset($emailMessage->to[$key]);
}
}
$emailRecipients = array_merge($emailRecipients, $emailMessage->to);
}
if (!empty($emailMessage->cc)) {
foreach ($emailMessage->cc as $key => $value) {
$emailMessage->cc[$key]['type'] = EmailMessageRecipient::TYPE_CC;
if ($value['email'] == Yii::app()->imap->imapUsername) {
unset($emailMessage->cc[$key]);
}
}
$emailRecipients = array_merge($emailRecipients, $emailMessage->cc);
}
}
if (count($emailRecipients) == 0) {
throw new NotSupportedException();
}
$emailRecipients = ArrayUtil::arrayUniqueRecursive($emailRecipients);
//After removing duplicates email get removed if its the same as name
foreach ($emailRecipients as $key => $emailRecipient) {
if (!isset($emailRecipient['email'])) {
$emailRecipients[$key]['email'] = $emailRecipient['name'];
}
}
return $emailRecipients;
}
示例3: arrayUniqueRecursive
public static function arrayUniqueRecursive($array)
{
$result = array_map("unserialize", array_unique(array_map("serialize", $array)));
foreach ($result as $key => $value) {
if (is_array($value)) {
$result[$key] = ArrayUtil::arrayUniqueRecursive($value);
}
}
return $result;
}
示例4: resolveEmailRecipientsFromEmailMessage
/**
* Get recipient details from email message.
* Have to cover two cases: when message is CC-ed or BCC-ed to dropbox,
* and when email message is forwarded to dropbox.
* 1. If message is CC-ed or BCC-ed to dropbox, recipients can be exctracted from "To" field of email message
* 2. If message is forwarded, then email from which message is forwarded to dropbox is recipient
* @param ImapMessage $emailMessage
* @param array $emailRecipient
*/
public static function resolveEmailRecipientsFromEmailMessage(ImapMessage $emailMessage)
{
// Check if email is forwarded or not.
if (self::isMessageForwarded($emailMessage)) {
// Somebody sent email to Zurmo user, the user forwarded it to dropbox, so the user is a recipient
$emailRecipients = array(array('email' => $emailMessage->fromEmail, 'name' => $emailMessage->fromName, 'type' => EmailMessageRecipient::TYPE_TO));
} else {
// Zurmo user sent email, so recipients are in 'To' and 'CC' fields
foreach ($emailMessage->to as $key => $value) {
$emailMessage->to[$key]['type'] = EmailMessageRecipient::TYPE_TO;
if ($value['email'] == Yii::app()->imap->imapUsername) {
unset($emailMessage->to[$key]);
}
}
$emailRecipients = $emailMessage->to;
if (!empty($emailMessage->cc)) {
foreach ($emailMessage->cc as $key => $value) {
$emailMessage->cc[$key]['type'] = EmailMessageRecipient::TYPE_CC;
if ($value['email'] == Yii::app()->imap->imapUsername) {
unset($emailMessage->cc[$key]);
}
}
$emailRecipients = ArrayUtil::arrayUniqueRecursive(array_merge($emailRecipients, $emailMessage->cc));
}
}
return $emailRecipients;
}