Advertisement
basart1

Untitled

Mar 11th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <?php
  2. $arraystring = ['cat','test','catty', 'meow'];
  3. $letter = 'ty';
  4.  
  5. function checkEarraystring ($arraystring,$letter) {
  6. $array = array();
  7. $indexofarray = 0;
  8. $indexofletter = 0;
  9. for ($i = 0; $i <count($arraystring); $i++) {
  10. $indexofletter = 0;
  11. for ($j = 0; $j <count($arraystring[$i]); $j++) {
  12. if (($arraystring[$i][$j] === $letter[$indexofletter]) === true) {
  13. $indexofletter++;
  14. if($indexofletter === count($letter)){
  15. $array[$indexofarray] = $arraystring[$i];
  16. $indexofarray++;
  17. }
  18. } else {
  19. $indexofletter = 0;
  20. if (($arraystring[$i][$j] === $letter[$indexofletter]) === true) {
  21. $indexofletter++;
  22. if($indexofletter === count($letter)){
  23. $array[$indexofarray] = $arraystring[$i];
  24. $indexofarray++;
  25. }
  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