当前位置: 首页>>代码示例>>PHP>>正文


PHP array_udiff函数代码示例

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


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

示例1: switchAction

 /**
  * Switch Context.
  *
  * @Route("/switch/{context}/{values}", name="bigfoot_context_switch")
  */
 public function switchAction($context, $values)
 {
     $values = explode(',', $values);
     $chosenContexts = array($context => $values);
     $user = $this->getUser();
     $requestStack = $this->getRequestStack();
     if ($this->getContextManager()->isEntityContextualizable(get_class($user), $context)) {
         $context = $this->getEntityManager()->getRepository('BigfootContextBundle:Context')->findOneByEntityIdEntityClass($user->getId(), get_class($user));
         if ($context) {
             $allowedContexts = $context->getContextValues();
             $contextsIntersect = array_udiff($chosenContexts, $allowedContexts, array($this, 'intersectContexts'));
             $sessionChosenContexts = $this->getSession()->get('bigfoot/context/chosen_contexts');
             if ($sessionChosenContexts) {
                 $contextsDiff = array_udiff($contextsIntersect, $sessionChosenContexts, array($this, 'diffContexts'));
             }
             if (isset($contextsDiff) && !$contextsDiff) {
                 $this->getSession()->set('bigfoot/context/chosen_contexts', null);
             } else {
                 $this->getSession()->set('bigfoot/context/chosen_contexts', $contextsIntersect);
             }
         } else {
             $this->getSession()->set('bigfoot/context/chosen_contexts', $chosenContexts);
         }
     } else {
         $this->getSession()->set('bigfoot/context/chosen_contexts', $chosenContexts);
     }
     return $this->redirect($requestStack->headers->get('referer'));
 }
开发者ID:7rin0,项目名称:BigfootContextBundle,代码行数:33,代码来源:ContextController.php

示例2: execute

 public function execute(array $collection)
 {
     $comparer = $this->getComparer();
     return array_values(array_udiff($collection, $this->collectionToExcept, function ($a, $b) use($comparer) {
         return $comparer->equals($a, $b);
     }));
 }
开发者ID:pablozabo,项目名称:Diarco,代码行数:7,代码来源:ExceptQuery.php

示例3: removeUnit

 function removeUnit(Unit $unit)
 {
     // удаление объекта типа Unit
     $this->units = array_udiff($this->units, [$unit], function ($a, $b) {
         return $a === $b ? 0 : 1;
     });
 }
开发者ID:Overfinch,项目名称:oop,代码行数:7,代码来源:index.php

示例4: PersistRelationshipChanges

 protected function PersistRelationshipChanges(Object\Domain $Domain, Object\UnitOfWork $UnitOfWork, $ParentEntity, $CurrentValue, $HasOriginalValue, $OriginalValue)
 {
     $RelationshipChanges = [];
     $OriginalEntities = [];
     $CurrentEntities = [];
     if ($HasOriginalValue) {
         $OriginalEntities =& $OriginalValue;
     }
     if (is_array($CurrentValue)) {
         $CurrentEntities =& $CurrentValue;
     } else {
         throw new Object\ObjectException('Invalid value for property on entity %s, array expected, %s given', $this->GetEntityType(), \Storm\Core\Utilities::GetTypeOrClass($CurrentValue));
     }
     if ($CurrentEntities === $OriginalEntities) {
         return $RelationshipChanges;
     }
     $NewEntities = array_udiff($CurrentEntities, $OriginalEntities, [$this, 'ObjectComparison']);
     $RemovedEntities = array_udiff($OriginalEntities, $CurrentEntities, [$this, 'ObjectComparison']);
     foreach ($NewEntities as $NewEntity) {
         $RelationshipChanges[] = new Object\RelationshipChange($this->RelationshipType->GetPersistedRelationship($Domain, $UnitOfWork, $ParentEntity, $NewEntity), null);
     }
     foreach ($RemovedEntities as $RemovedEntity) {
         $RelationshipChanges[] = new Object\RelationshipChange(null, $this->RelationshipType->GetDiscardedRelationship($Domain, $UnitOfWork, $ParentEntity, $RemovedEntity));
     }
     return $RelationshipChanges;
 }
开发者ID:timetoogo,项目名称:penumbra,代码行数:26,代码来源:ArrayProperty.php

示例5: compareCallbacks

 /**
  * Returns true if the callbacks $a and $b are the same.
  *
  * @param callback $a
  * @param callback $b
  * @return bool
  */
 public static function compareCallbacks($a, $b)
 {
     if (is_string($a) || is_string($b)) {
         return $a === $b;
     }
     return count(array_udiff($a, $b, array('ezcSignalCallbackComparer', 'comp_func'))) == 0;
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:14,代码来源:callback_comparer.php

示例6: testUpdateTimeOnly

 /**
  * Tests that updating the start time of an event keeps the occurrence IDs.
  * This *may* change as occurrences may be able to share the same date
  * @see https://github.com/stephenharris/Event-Organiser/issues/240 
  * 
  * @see https://wordpress.org/support/topic/all-events-showing-1200-am-as-start-and-end-time
  * @see https://github.com/stephenharris/Event-Organiser/issues/195
  */
 public function testUpdateTimeOnly()
 {
     $tz = eo_get_blog_timezone();
     $event = array('start' => new DateTime('2013-10-19 15:30:00', $tz), 'end' => new DateTime('2013-10-19 15:45:00', $tz), 'frequeny' => 1, 'schedule' => 'weekly', 'number_occurrences' => 4);
     //Create event and store occurrences
     $event_id = eo_insert_event($event);
     $original_occurrences = eo_get_the_occurrences($event_id);
     //Update event
     $new_event_data = $event;
     $new_event_data['start'] = new DateTime('2013-10-19 14:30:00', $tz);
     eo_update_event($event_id, $new_event_data);
     //Get new occurrences
     $new_occurrences = eo_get_the_occurrences($event_id);
     //Compare
     $added = array_udiff($new_occurrences, $original_occurrences, '_eventorganiser_compare_dates');
     $removed = array_udiff($original_occurrences, $new_occurrences, '_eventorganiser_compare_dates');
     $updated = array_intersect_key($new_occurrences, $original_occurrences);
     $updated_2 = array_intersect_key($original_occurrences, $new_occurrences);
     $updated = $this->array_map_assoc('eo_format_datetime', $updated, array_fill(0, count($updated), 'Y-m-d H:i:s'));
     $updated_2 = $this->array_map_assoc('eo_format_datetime', $updated_2, array_fill(0, count($updated_2), 'Y-m-d H:i:s'));
     //Check added/removed/update dates are as expected: all dates should just be updated
     $this->assertEquals(array(), $added);
     $this->assertEquals(array(), $removed);
     $this->assertEquals(array('2013-10-19 14:30:00', '2013-10-26 14:30:00', '2013-11-02 14:30:00', '2013-11-09 14:30:00'), array_values($updated));
     //Now check that dates have been updated as expected (i.e. there have been no 'swapping' of IDs).
     //First: Sanity check, make sure IDs agree.
     $diff = array_diff_key($updated, $updated_2);
     $this->assertTrue(empty($diff) && count($updated) == count($updated_2));
     ksort($updated);
     ksort($updated_2);
     $updated_map = array_combine($updated_2, $updated);
     //Now check that the dates have been updated as expected: original => new
     $this->assertEquals(array('2013-10-19 15:30:00' => '2013-10-19 14:30:00', '2013-10-26 15:30:00' => '2013-10-26 14:30:00', '2013-11-02 15:30:00' => '2013-11-02 14:30:00', '2013-11-09 15:30:00' => '2013-11-09 14:30:00'), $updated_map);
 }
开发者ID:Borgoroth,项目名称:Event-Organiser,代码行数:42,代码来源:eventTest.php

示例7: removeUnit

 /**
  * @param Unit $unit
  * @return $this|void
  */
 public function removeUnit(Unit $unit)
 {
     $this->units = array_udiff($this->units, [$unit], function ($a, $b) {
         return $a === $b ? 0 : 1;
     });
     return $this;
 }
开发者ID:Codealist,项目名称:patterns,代码行数:11,代码来源:CompositeUnit.php

示例8: bookingAction

 /**
  *@Security("has_role('ROLE_USER')")
  *@Route("/programme/booking/{projection_id}", name ="booking")
  */
 public function bookingAction(Request $request, $projection_id)
 {
     $em = $this->getDoctrine()->getManager();
     //retrieve a projection from the database
     $projection = $em->getRepository('AppBundle:Projection')->find($projection_id);
     //all seats available for the projection
     $allSeats = $projection->getHall()->getSeats()->toArray();
     //get reserved tickets for the projection
     $reservedTickets = $em->createQueryBuilder()->select('t')->from('AppBundle:Ticket', 't')->where('t.projection = ?1')->setParameter(1, $projection)->getQuery()->getResult();
     //get reserved seats for the projection
     $reservedSeats = array();
     foreach ($reservedTickets as $ticket) {
         $reservedSeats[] = $ticket->getSeat();
     }
     // get free seats
     $freeSeats = array_udiff($allSeats, $reservedSeats, function ($hallSeat, $reservedSeat) {
         return $hallSeat->getId() - $reservedSeat->getId();
     });
     //a ticket which will be stored
     $ticket = new Ticket();
     $form = $this->createForm(new BookProjectionForm($freeSeats), $ticket);
     $form->handleRequest($request);
     if ($form->isValid()) {
         //set the other fields
         $ticket->setUser($this->getUser())->setProjection($projection)->setTicketPrice($ticket->getPriceCategory()->getCategoryPrice())->setBookingDate(new \DateTime('now'));
         $em->persist($ticket);
         $em->flush();
         // redirect to reservations page
         return $this->redirectToRoute('reservations');
     }
     return $this->render('User/booking.html.twig', array('projection' => $projection, 'form' => $form->createView()));
 }
开发者ID:MarekBielik,项目名称:Druzba-Cinema,代码行数:36,代码来源:UserBookingController.php

示例9: parse

 /**
  * Parses the search text to a query wich will search in each of the specified fields.
  * If operators AND, OR or NOT are used in the text it is considered search text query and is passed as it is.
  * If it is a simple text - it is escaped and truncated.
  * 
  * @param string $searchText
  * @param array $fields
  * @param string $truncate
  */
 public function parse($searchText, $truncate, $fields)
 {
     $nonTokenizedFields = array_uintersect($fields, self::$_nonTokenizedFields, array('OpenSKOS_Solr_Queryparser_Editor_ParseSearchText', 'compareMultiLangFields'));
     $fields = array_udiff($fields, self::$_nonTokenizedFields, array('OpenSKOS_Solr_Queryparser_Editor_ParseSearchText', 'compareMultiLangFields'));
     $simpleFieldsQuery = '';
     $normalFieldsQuery = '';
     if ($this->_isSearchTextQuery($searchText)) {
         $simpleFieldsQuery = $this->_buildQueryForSearchTextInFields('(' . $searchText . ')', $nonTokenizedFields);
         $normalFieldsQuery = $this->_buildQueryForSearchTextInFields('(' . $searchText . ')', $fields);
     } else {
         $trimedSearchText = trim($searchText);
         if (empty($trimedSearchText)) {
             $searchText = '*';
         }
         $searchTextForNonTokenized = $this->_escapeSpecialChars($searchText);
         $simpleFieldsQuery = $this->_buildQueryForSearchTextInFields('(' . $searchTextForNonTokenized . ')', $nonTokenizedFields);
         $searchTextForTokenized = $this->_replaceTokenizeDelimiterChars($searchText);
         $normalFieldsQuery = $this->_buildQueryForSearchTextInFields('(' . $searchTextForTokenized . ')', $fields);
     }
     if ($simpleFieldsQuery != '' && $normalFieldsQuery != '') {
         return $simpleFieldsQuery . ' OR ' . $normalFieldsQuery;
     } else {
         return $simpleFieldsQuery . $normalFieldsQuery;
     }
 }
开发者ID:rubensworks,项目名称:OpenSKOS,代码行数:34,代码来源:ParseSearchText.php

示例10: index

 /**
  *
  */
 public function index()
 {
     if ($this->session->userdata('logged_in')) {
         $thisUserID = $this->session->userdata('logged_in')['userID'];
         $courses = $this->Model_course->GetAllCourses();
         $userCourses = $this->Model_usercourse->GetUserCourses($thisUserID);
         if ($courses) {
             $coursesAvail = array_udiff($courses, $userCourses, function ($courses, $userCourses) {
                 return $courses->courseID - $userCourses->courseID;
             });
             $data['courses'] = $courses;
             $data['coursesAvail'] = $coursesAvail;
             $data['count_coursesAvail'] = count($coursesAvail);
         }
         //List of courses the user is enrolled in
         if ($userCourses) {
             $data['userCourses'] = $userCourses;
         }
         //Count of courses the user is enrolled in
         $count = $this->Model_usercourse->GetNumberOfUserCourses();
         if ($count) {
             $data['NoOfUserCourses'] = $count;
         }
         //Count of the total nunmber of courses
         $count = $this->Model_course->GetNumberOfCourses();
         if ($count) {
             $data['NoOfCourses'] = $count;
         }
         //Count of the number of groups in the system
         $count = $this->Model_group->GetNumberofGroups();
         if ($count) {
             $data['NoOfGroups'] = $count;
         }
         //List of groups in the system
         $groups = $this->Model_group->GetGroups();
         if ($groups) {
             $data['userGroups'] = $groups;
         }
         $session_data = $this->session->userdata('logged_in');
         $data['userID'] = $session_data['userID'];
         $data['fname'] = $session_data['fname'];
         $data['lname'] = $session_data['lname'];
         $data['usertype'] = $session_data['usertype'];
         $data['email'] = $session_data['email'];
         $data['menu'] = "home";
         //List of courses completed by a user, null if there is none
         $query = $this->Model_usercourse->GetCompletedUserCourse($data['userID']);
         if ($query) {
             $data['completedUserCourses'] = $query;
         } else {
             $data['completedUserCourses'] = null;
         }
         $this->load->view('header', $data);
         $this->load->view('view_dashboard');
     } else {
         //If no session, redirect to login page
         redirect('login', 'refresh');
     }
 }
开发者ID:ruchern,项目名称:auscert,代码行数:62,代码来源:home.php

示例11: removeUnit

 function removeUnit(Unit $unit)
 {
     // >= php 5.3
     //$this->units = array_udiff( $this->units, array( $unit ),
     //                function( $a, $b ) { return ($a === $b)?0:1; } );
     // < php 5.3
     $this->units = array_udiff($this->units, array($unit), create_function('$a,$b', 'return ($a === $b)?0:1;'));
 }
开发者ID:jabouzi,项目名称:projet,代码行数:8,代码来源:listing10.08.php

示例12: execute

 public function execute(array $collection)
 {
     $comparer = $this->getComparer();
     $diffed = array_udiff($this->additionalCollection, $collection, function ($a, $b) use($comparer) {
         return $comparer->equals($a, $b);
     });
     return array_merge($collection, $diffed);
 }
开发者ID:pablozabo,项目名称:Diarco,代码行数:8,代码来源:UnionQuery.php

示例13: detach

 function detach(Observer $observer)
 {
     // >= php 5.3
     //$this->observers = array_udiff( $this->observers, array( $observer ),
     //                function( $a, $b ) { return ($a === $b)?0:1; } );
     // < php 5.3
     $this->observers = array_udiff($this->observers, array($observer), create_function('$a,$b', 'return ($a === $b)?0:1;'));
 }
开发者ID:jabouzi,项目名称:projet,代码行数:8,代码来源:listing11.06.5.php

示例14: removePermission

 /**
  * {@inheritdoc}
  */
 public function removePermission(PermissionInterface $permission)
 {
     if ($this->hasPermission($permission)) {
         $this->permissions = array_udiff($this->permissions, [$permission], function ($objectA, $objectB) {
             return $objectA->getHash() - $objectB->getHash();
         });
     }
     return $this;
 }
开发者ID:johnathanmdell,项目名称:identity,代码行数:12,代码来源:Role.php

示例15: diff

 public static function diff(array $a, array $b)
 {
     return array_udiff($a, $b, function ($a, $b) {
         if (gettype($a) !== gettype($b)) {
             return -1;
         }
         return $a === $b ? 0 : 1;
     });
 }
开发者ID:phindmarsh,项目名称:statham,代码行数:9,代码来源:Utils.php


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