php remove space before and after string

Solutions on MaxInterview for php remove space before and after string by the best coders in the world

showing results for - "php remove space before and after string"
Bianca
23 Jul 2020
1<?php
2$stripped = str_replace(' ', '', "10 1000 0000 000");
3echo $stripped;
Nisha
23 Mar 2018
1 
2$trimmed = trim($text);
3var_dump($trimmed);
4
5 
6
Caden
02 Jul 2017
1$words = '      my words     ';
2$words = trim($words);
3var_dump($words);
4// string(8) "my words"
5
Alina
16 Oct 2019
1<?php
2
3$text   "\t\tThese are a few words :) ...  ";
4$binary "\x09Example string\x0A";
5$hello  "Hello World";
6var_dump($text$binary$hello);
7
8print "\n";
9
10$trimmed = trim($text);
11var_dump($trimmed);
12
13$trimmed = trim($text" \t.");
14var_dump($trimmed);
15
16$trimmed = trim($hello"Hdle");
17var_dump($trimmed);
18
19$trimmed = trim($hello'HdWr');
20var_dump($trimmed);
21
22// trim the ASCII control characters at the beginning and end of $binary
23// (from 0 to 31 inclusive)
24$clean = trim($binary"\x00..\x1F");
25var_dump($clean);
26
27?>
similar questions
queries leading to this page
php remove space before and after string