Foreach Looping Using In_array

Page 1 of 1

1 Replies - 279 Views - Last Post: 22 March 2013 - 08:15 AM Rate Topic: -----

#1 rooster_bob  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 21-March 13

Foreach Looping Using In_array

Posted 22 March 2013 - 08:10 AM

<code>
$frogs = array('Tree Frog' => 'Tree Frog', 'Arrow Frog' => 'Arrow Frog', 'Dart Frog' => 'Dart Frog', 'Toad' => 'Toad');
	 
	foreach ($frogs as $key => $val) {
	 if (! in_array($value, $frogs) )  {
	    $form_output_message_errors[] = 'Please choose a valid type of frog.';
	  }
	}
</code>


I want to loop through my frogs array and compare what is actually in the array vs. what the user attempts to submit ONLY using a foreach loop. What changes should I make to my code?

This post has been edited by modi123_1: 22 March 2013 - 08:14 AM
Reason for edit:: highlight the text and just click the 'code' button in the text editor


Is This A Good Question/Topic? 0
  • +

Replies To: Foreach Looping Using In_array

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8954
  • View blog
  • Posts: 33,564
  • Joined: 12-June 08

Re: Foreach Looping Using In_array

Posted 22 March 2013 - 08:15 AM

Do not create duplicate topics. Use the existing one. Closing.

http://www.dreaminco...reach-question/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1