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 return;
}
if (! $error = trim($buffer)) {
return true;
}
<?php public function format($url)
{
return self::tidy('/'.trim($url, '/'));
}
<?php return collect(explode(',', $addresses))->map(function ($address) {
$name = null;
$email = trim($address);
if (Str::contains($email, '<')) {
preg_match('/^(.*) \<(.*)\>$/', $email, $matches);
<?php 'container' => 'required',
'folder' => 'required',
'file' => ['file', function ($attribute, $value, $fail) {
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'phtml'])) {
$fail(__('validation.uploaded'));
}
}],
<?php protected function camelToWords($name)
{
$label = strtolower(trim(str_replace([
'-',
'_',
'.',
], ' ', preg_replace('/(?<![A-Z])[A-Z]/', ' \0', $name))));
return $label;
}
<?php if ($mimetype = $response->getHeader('Content-Type')) {
[$mimetype] = explode(';', reset($mimetype), 2);
return trim($mimetype);
}
<?php public function deslugify($value)
{
return trim(preg_replace('~[-_]~', ' ', $value), ' ');
}
<?php public function wordCount($value)
{
$words = empty($string = trim($value)) ? [] : preg_split('~[^\p{L}\p{N}\']+~u', $value);
return count($words);
}
<?php public function passes($attribute, $value)
{
return User::query()->where('email', trim($value))->count() === 0;
}
<?php private function preformat($raw_query)
{
return trim(mb_ereg_replace("[^\w\d\-\.:+\s&’'‘]", '', $raw_query));
}
<?php $output = preg_replace('/[\r\n]+$/', '', $output);
if (! empty(trim($output))) {
$this->console->line($output);
}
<?php $prefix = '';
if (class_exists(Nova::class)) {
$prefix = '(?!'.trim(Nova::path(), '/').')';
}
return $prefix.'.*';
<?php }
if ($this->params->bool('trim', true)) {
$this->content = trim($this->content);
}
$crumbs = $crumbs->values()->map(function ($crumb) {
<?php {
$variables = array_merge($this->context->all(), $this->params->all(), [
'__frontmatter' => $this->params->all(),
'slot' => $this->isPair ? trim($this->parse()) : null,
]);
return view($this->viewName($partial), $variables)
<?php foreach ($this->files->allFiles($this->paths) as $file) {
if (preg_match_all('/'.$this->methodRegex().'/imu', $file->getContents(), $matches)) {
foreach ($matches[2] as $match) {
$strings[] = trim(stripcslashes($match));
}
}