Advertisement
Guest User

Untitled

a guest
Feb 14th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. $result = [];
  2. $inBlock = false;
  3. $block = [];
  4. for ($i = 0; $i < count($array); $i++) {
  5.     $current = $array[$i];
  6.     if ($inBlock) {
  7.         $valid = false;
  8.         foreach ($payloads as $payload) {
  9.             if (strpos($current, $payload) === 0) {
  10.                 $valid = true;
  11.             }
  12.         }
  13.  
  14.         if ($valid) {
  15.             $block[] = $current;
  16.         } elseif ($current === $end) {
  17.             $result = array_merge($result, $block, ['|']);
  18.         }
  19.  
  20.         $inBlock = $valid;
  21.     } elseif (strpos($current, $start) === 0) {
  22.         $block = [$current];
  23.         $inBlock = true;
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement