Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.32 KB | None | 0 0
  1. function findInArray($search, $arr){
  2.     $return = [];
  3.     foreach($arr as $a){
  4.         if(strpos($a, $search) !== false){
  5.               $return[] = $a;
  6.             }
  7.     }
  8.     return $return;
  9. }
  10.  
  11. $arr = [
  12.     'one',
  13.     'two',
  14.     'three',
  15.     'four',
  16.     'fourteen',
  17.     'fourty',
  18.     'not fourty'
  19. ];
  20.  
  21. findInArray("four", $arr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement