Advertisement
basart1

Untitled

Mar 10th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.21 KB | None | 0 0
  1. <?php
  2. $arraystring = ['cat','test','catty', 'meow'];
  3. $letter = 'ca';
  4. checkEarraystring($arraystring,$letter);
  5. function checkEarraystring ($arraystring,$letter)
  6. {
  7.     $array = array();
  8.     $indexofarray = 0;
  9.     $indexofletter1 = 0;
  10.     for ($i = 0; $i <count($arraystring); $i++) {
  11.         for  ($j = 0; $j < count($arraystring[$i]); $j++) {
  12.             $indexofletter = 0;
  13.             if (($arraystring[$i][$j] == $letter[$indexofletter1]) === true) {
  14.                 $indexofletter++;
  15.                 if($indexofletter==(count($letter))){
  16.                     $array[$indexofarray] = $arraystring[$i];
  17.                     $indexofarray++;
  18.                 }
  19.             } else {
  20.                 $indexofletter = 0;
  21.                 if (($arraystring[$i][$j] == $letter[$indexofletter]) === true) {
  22.                     $indexofletter++;
  23.                     if($indexofletter == count($letter)){
  24.                         $array[$indexofarray] = $arraystring[$i];
  25.                         $indexofarray++;
  26.                     }}
  27.             }
  28.         }
  29.     }
  30.     if (count($array) === 0){
  31.         echo("нихуя не найдено");
  32.     }
  33.     return $array;
  34. }
  35. var_dump(checkEarraystring($arraystring,$letter));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement