Insert a space between 2 echo

Asked
Active3 hr before
Viewed126 times

6 Answers

space
90%

Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers ,How do I add a space in the returned text between sample1 and sample2? Here is what I have so far:, @alex I didn't say it doesn't, both ways works.. Since he asked about concatenation, I said something about the dot and not multiple echo params, since you can't always "concatenate" strings with commas – Thiago Belem Feb 10 '12 at 6:38 ,Please be sure to answer the question. Provide details and share your research!

It's really simple, just echo a space between the variables...

< ? php
if ($eventid != "") {
   echo $get_event['sample1'], ' ', $get_event['sample2'];
}
load more v
88%

It's really simple, just echo a space between the variables...,How do I add a space in the returned text between sample1 and sample2? Here is what I have so far:,   php  -  echo  -  space ,Indentation always make things cleaner and easier:

How do I add a space in the returned text between sample1 and sample2? Here is what I have so far:

if ($eventid != "") {
   echo $get_event['sample1'], $get_event['sample2'];
}
load more v
72%

Example #2 Trimming array values with trim(), This function returns a string with whitespace stripped from the beginning and end of string. Without the second parameter, trim() will strip these characters: ,ltrim() - Strip whitespace (or other characters) from the beginning of a string,trim — Strip whitespace (or other characters) from the beginning and end of a string

string(32)
"        These are a few words :) ...  "
string(16)
"    Example string
"
string(11)
"Hello World"

string(28)
"These are a few words :) ..."
string(24)
"These are a few words :)"
string(5)
"o Wor"
string(9)
"ello Worl"
string(14)
"Example string"
load more v
65%

Put your variable inside double quote to prevent field splitting, which ate your spaces:,The reason why quoting is needed in your case is because without it bash applies the split+glob operator onto the expansion of $MYCUSTOMTAB. The default value of $IFS contains the TAB character, so in echo -e $MYCUSTOMTAB"blah blah", $MYCUSTOMTAB is just split into nothing so it becomes the same as if you had written:, 1 Put the variable inside double quotes. This is one of the main reasons we constantly harp "quote your variables". Security implications of forgetting to quote a variable in bash/POSIX shells – glenn jackman Apr 1 '16 at 14:44 , 2 printf is "better" if you use it properly: you need to write printf "blah%sblah\n" "$MYCUSTOMTAB" -- if the variable contains any %s, %d, etc, you'll get the wrong output otherwise. – glenn jackman Apr 1 '16 at 14:51

Put your variable inside double quote to prevent field splitting, which ate your spaces:

$ MYCUSTOMTAB = '     '
$ echo "${MYCUSTOMTAB}blah blah"
blah blah
load more v
75%

The &emsp; character entity used to denote an ’em’ space which means equal to the point size of the current font. This may be perceived as four times the space of a normal space.,The &ensp; character entity used to denote an ‘en’ space which means half point size of the current font. This may be perceived as twice the space of a normal space.,The &nbsp; character entity used to denote a non-breaking space which is a fixed space. This may be perceived as twice the space of a normal space. It is used to create a space in a line that cannot be broken by word wrap.,In the above code the regular space and two space  and four space gaps code is not visible so here is how it looks

Syntax:

Regular space: & nbsp;
Two spaces gap: & ensp;
Four spaces gap: & emsp;

Syntax:

.tab {
   tab - size: 2;
}

Syntax:

.tab {
   display: inline - block;
   margin - left: 40 px;
}
load more v
40%

Youcaneasilydothisbyhighlightingyourcode.
load more v

Other "space-undefined" queries related to "Insert a space between 2 echo"