Reply to Re: [PHP] Trouble figuring out a Walk through an Array

Your name:

Reply:


Posted by Richard Davey on 10/13/05 19:10

Hi Phillip,

Thursday, October 13, 2005, 4:56:30 PM, you wrote:

> Having trouble figureing out a certain walk through an array.
> And I am not finding the help I need in the manual or anything.

> I have an associative arr ($arr) With about 20 elements in it.
> Ten of which are required. So I have another associative array called
> $required, with all the elements in the array that are required.

> I have initaited a foreach loop on the $arr splitting things into $key and
> $value.

> Now the part I am having trouble with is this.

> I want to see if $key matches any of the values in $required. If so do
> something in particular. If not then do something else. It does not
> particularly matter which value in the $required it matches, just so long as
> it matches.

While for-eaching through your $arr you could simply do an:

if (in_array($key, $required))

Unless you need something more complex than this?

Cheers,

Rich
--
Zend Certified Engineer
http://www.launchcode.co.uk

[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

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