Re: array_intersect()

From: Date: Fri, 19 Jan 2001 22:26:17 +0000
Subject: Re: array_intersect()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-35740@lists.php.net to get a copy of this message
ok, Ive got my code to work, but its a big jerry-rig haha. because I am using mtime() (the last two chars are allways 00) I substr the last two chars off, array_insersect() them, then add 00 the the end of all the values in the result array. dumb eh. Chris Lee Mediawaveonline.com "Chris Lee" <lee@mediawaveonline.com> wrote in message news:94abie$j8q$1@toye.p.sourceforge.net... > > Ok I thought array_intersect() was the function I was looking for, I might > have to write my own. > > I want an array with ONLY the keys/values that are present in all the > variables; ie. > > <? > $test_a[] = '974806802083190501'; > $test_a[] = '974806802083190503'; > $test_a[] = '974806802083190504'; > > $test_b[] = '974806802083190501'; > > $new_array = array_intersect($test_a, $test_b); > > print_r($new_array); > ?> > > Array > ( > [0] => 974806802083190501 > [1] => 974806802083190503 > [2] => 974806802083190504 > ) > > <? > $test_a[] = '501'; > $test_a[] = '503'; > $test_a[] = '504'; > > $test_b[] = '501'; > > $new_array = array_intersect($test_a, $test_b); > > print_r($new_array); > ?> > > Array > ( > [0] => 501 > ) > > array_insersect() only seems to work with small numbers... or small text. > > Chris Lee > Mediawaveonline.com > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#35740) next »