Eduardokum\LaravelBoleto\Util::remove PHP Method

remove() public static method

Remove trecho do array.
public static remove ( $i, $f, &$array ) : string
$i
$f
$array
return string
    public static function remove($i, $f, &$array)
    {
        if (is_string($array)) {
            $array = str_split(rtrim($array, chr(10) . chr(13) . "\n" . "\r"), 1);
        }
        $i--;
        if ($i > 398 || $f > 400) {
            throw new \Exception('$ini ou $fim ultrapassam o limite máximo de 400');
        }
        if ($f < $i) {
            throw new \Exception('$ini é maior que o $fim');
        }
        $t = $f - $i;
        $toSplice = $array;
        return trim(implode('', array_splice($toSplice, $i, $t)));
    }

Usage Example

 /**
  * Remove trecho do array.
  *
  * @param $i
  * @param $f
  * @param $array
  *
  * @return string
  * @throws \Exception
  */
 protected function rem($i, $f, &$array)
 {
     return Util::remove($i, $f, $array);
 }