[PHP] Array query
Hi, say I have two arrays: X and Y. How can i get the values I X that arent in Y and assign them to another array? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array query
www.php.net/array_diff shaun wrote: Hi, say I have two arrays: X and Y. How can i get the values I X that arent in Y and assign them to another array? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Array query - finding the key for a value
This may be a silly question, but I'm used to being able to find PHP functions to do whatever I want, but I can't find one to do this! If I have an array like this: [0] - 'apple'; [1] - 'pear'; [2] - 'orange'; [3] - 'apricot'; I know I can use in_array() to check whether, say, 'orange' is in the array; but how do I then find out which index 'orange' is at? -- Tim Fountain ([EMAIL PROTECTED]) http://www.tfountain.co.uk/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array query - finding the key for a value
On Friday 16 August 2002 19:50, Tim Fountain wrote: This may be a silly question, but I'm used to being able to find PHP functions to do whatever I want, but I can't find one to do this! If I have an array like this: [0] - 'apple'; [1] - 'pear'; [2] - 'orange'; [3] - 'apricot'; I know I can use in_array() to check whether, say, 'orange' is in the array; but how do I then find out which index 'orange' is at? array_search() -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* The more things change, the more they'll never be the same again. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Array query - finding the key for a value
From: Tim Fountain [mailto:[EMAIL PROTECTED]] Sent: Friday, August 16, 2002 7:51 AM Subject: [PHP] Array query - finding the key for a value This may be a silly question, but I'm used to being able to find PHP functions to do whatever I want, but I can't find one to do this! If I have an array like this: [0] - 'apple'; [1] - 'pear'; [2] - 'orange'; [3] - 'apricot'; I know I can use in_array() to check whether, say, 'orange' is in the array; but how do I then find out which index 'orange' is at? http://www.php.net/manual/en/function.array-search.php Note that it will return 0 if the value is in the first element of the array so use ( === ) to determine if it's a key or really not found. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php