Reply to Re: Help: questions about query structure in imap_search

Your name:

Reply:


Posted by Colin McKinnon on 01/20/06 23:24

chris_fieldhouse@hotmail.com wrote:


>
> I've ended up with this rather unsatisfying piece of code, it works,
> but it looks like a cludge.
>

I've seen worse.

> <code snippet>
> # now lets try searching for TO and CC emails! merge arrays,
> $emailSearch1= imap_search($conn, "TO test_address");
> $emailSearch2= imap_search($conn, "CC test_address");
>
> # attempt to merge arrays
> $emailSearch= array_merge ($emailSearch1, $emailSearch2);
>
> # if one array is 'empty', just assign the other array to be the search
> result
> if($emailSearch1 == false) $emailSearch=$emailSearch2;
> if($emailSearch2 == false) $emailSearch=$emailSearch1;
>


$results=array();
foreach(array('TO test_address','CC test address') as $iqry) {
if ($false !== ($sub = imap_search($conn, $iqry))) {
$results = array_merge($results, $sub);
}
}

....strikes me as more elegant - but less transparent. Also your code will
leave 'false' in the result when both queries fail, whereas my code returns
an empty array.

C.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация