public static function parseLines($text, $toAssoc = true): array
    {
        $text = htmlspecialchars_decode($text);
        $text = self::clean($text, false, false, false);

        $text = str_replace(["\n", "\r", "\r\n", PHP_EOL], "\n", $text);
        $lines = explode("\n", $text);

        $result = [];
        if (!empty($lines)) {
            foreach ($lines as $line) {
                $line = trim($line);

                if ($line === '') {
                    continue;
                }

                if ($toAssoc) {
                    $result[$line] = $line;
                } else {
                    $result[] = $line;
                }
            }
        }

        return $result;
    }
public static function parseLines($text, $toAssoc = true): array
    {
        $text = htmlspecialchars_decode($text);
        $text = self::clean($text, false, false, false);

        $text = str_replace(["\n", "\r", "\r\n", PHP_EOL], "\n", $text);
        $lines = explode("\n", $text);

        $result = [];
        if (!empty($lines)) {
            foreach ($lines as $line) {
                $line = trim($line);

                if ($line === '') {
                    continue;
                }

                if ($toAssoc) {
                    $result[$line] = $line;
                } else {
                    $result[] = $line;
                }
            }
        }

        return $result;
    }
public static function parseLines ( $ text , $ toAssoc = true ) : array { $ text = htmlspecialchars_decode ( $ text ) ; $ text = self :: clean ( $ text , false , false , false ) ; $ text = str_replace ( [ "\n" , "\r" , "\r\n" , PHP_EOL ] , "\n" , $ text ) ; $ lines = explode ( "\n" , $ text ) ; $ result = [ ] ; if ( ! empty ( $ lines ) ) { foreach ( $ lines as $ line ) { $ line = trim ( $ line ) ; if ( $ line === '' ) { continue ; } if ( $ toAssoc ) { $ result [ $ line ] = $ line ; } else { $ result [ ] = $ line ; } } } return $ result ; }
Parse text by lines

@param string $text
@param bool   $toAssoc
@return array
Parse text by lines