Answers for "why php for loop inside function return false"

PHP
0

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.
}
Posted by: Guest on December-06-2020

Code answers related to "why php for loop inside function return false"

Browse Popular Code Answers by Language