Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

return false inside loop of function php

$items = ['a' , 'b' , 'c']; 

foreach($items as $item) 
{ 
   if($item == 'a') 
   {
       return true; // the foreach will stop once 'a' is found and returns true. 
   }

   return false; // if 'a' is not found, the foreach will return false.
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #return #false #loop #function #php
ADD COMMENT
Topic
Name
6+6 =