Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Strip whitespace (or other characters) from the beginning and end of a string
<?php trim(string $string, string $characters = " \n\r\t\v\x00"): string
<?php     $connection->on('data', function ($data) use ($connection, $socket) {


        $data = trim(preg_replace('/[^\w\d \.\,\-\!\?]/u', '', $data));




        if ($data === '') {
<?php         }




        $data = trim(parse_url($connection->getRemoteAddress(), PHP_URL_HOST), '[]') . ': ' . $data . PHP_EOL;

        foreach ($socket->getConnections() as $connection) {

            $connection->write($data);

        }
<?php             ));

        }



        $host = \trim($parts['host'], '[]');

        $connector = $this->connector;
<?php             ));

        }



        $host = \trim($parts['host'], '[]');




        if (@\inet_pton($host) !== false) {
<?php             ));

        }



        $ip = \trim($parts['host'], '[]');

        if (@\inet_pton($ip) === false) {

            return Promise\reject(new \InvalidArgumentException(

                'Given URI "' . $uri . '" does not contain a valid host IP (EINVAL)',
<?php             );

        }



        if (@\inet_pton(\trim($parts['host'], '[]')) === false) {

            throw new \InvalidArgumentException(

                'Given URI "' . $uri . '" does not contain a valid host IP (EINVAL)',

                \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22