|
Posted by ZeldorBlat on 07/09/07 16:53
On Jul 9, 12:29 pm, odysseyphotography <i...@odysseyphotography.net>
wrote:
> Hi everyone,
>
> I was wondering if its possible to check if a given value appears in
> an array more than once?
>
> I need to code something which goes something along the lines of:
>
> Faux code ---
>
> if (in_array_twice($person, $already_emailed)) {
> echo $person . ' is in the array already, don't email them';} else {
>
> echo $person . ' is not in the array, its OK to email them';
>
> }
>
> ---
>
> If anyone has any ideas they'd be very much appreciated.
>
> Thanks,
>
> OP
function in_array_morethanonce($needle, array $haystack, $strict =
false) {
return (count(array_keys($haystack, $needle, $strict)) > 1);
}
Navigation:
[Reply to this message]
|