Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $arraystring = ['cat','test','catty', 'meow'];
- $letter = 'ty';
- function checkEarraystring ($arraystring,$letter) {
- $array = array();
- $indexofarray = 0;
- $indexofletter = 0;
- for ($i = 0; $i <count($arraystring); $i++) {
- $indexofletter = 0;
- for ($j = 0; $j <count($arraystring[$i]); $j++) {
- if (($arraystring[$i][$j] === $letter[$indexofletter]) === true) {
- $indexofletter++;
- if($indexofletter === count($letter)){
- $array[$indexofarray] = $arraystring[$i];
- $indexofarray++;
- }
- } else {
- $indexofletter = 0;
- if (($arraystring[$i][$j] === $letter[$indexofletter]) === true) {
- $indexofletter++;
- if($indexofletter === count($letter)){
- $array[$indexofarray] = $arraystring[$i];
- $indexofarray++;
- }
- }
- }
- }
- }
- if (count($array) === 0){
- echo("нихуя не найдено");
- }
- return $array;
- }
- var_dump(checkEarraystring($arraystring,$letter));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement