note 62802 added to function.array-diff
| From: | pavlicicatNOSPAMdothotmaildotcom at osu1 dot php dot net | Date: | Thu, 09 Mar 2006 21:55:26 +0000 |
| Subject: | note 62802 added to function.array-diff | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-105170@lists.php.net to get a copy of this message | ||
<?php
// first array
$vid_player = $vm->getVideosByPlayer($player);
// second array
$vid_playlist = $vm->getVideosByPlaylist($playlist);
// this will not work...
$vid_player = array_diff($vid_player, $vid_playlist);
// but if you do this first...
$videos = array();
foreach ( $vid_player as $player )
{
if ( $vid_playlist != null )
{
foreach ( $vid_playlist as $video )
{
if ( $player->id == $video->id )
$videos[] = $player;
}
}
}
// this will work...
$vid_player = array_diff($vid_player, $videos);
?>
The first array_diff() compares two arrays only to find out that all the objects are unique!
----
Server IP: 66.163.161.117
Probable Submitter: 137.224.223.213
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.array-diff.php
Edit -- http://master.php.net/note/edit/62802
Del: integrated -- http://master.php.net/note/delete/62802/integrated
Del: useless -- http://master.php.net/note/delete/62802/useless
Del: bad code -- http://master.php.net/note/delete/62802/bad+code
Del: spam -- http://master.php.net/note/delete/62802/spam
Del: non-english -- http://master.php.net/note/delete/62802/non-english
Del: in docs -- http://master.php.net/note/delete/62802/in+docs
Del: other reasons-- http://master.php.net/note/delete/62802
Reject -- http://master.php.net/note/reject/62802
Search -- http://master.php.net/manage/user-notes.php