I was wondering how can I add extra whitespace in php is it something like \\s
please help thanks.
Is there a tutorial that list these kind of things th
You can also use this
str_repeat("\x20", $numberOfRepeats);
use this one. it will provide 60 spaces. that is your second parameter.
echo str_repeat(" ", 60);
<?php
echo "<p>hello\n";
echo "world</p>";
echo "\n\n";
echo "<p>\n\tindented\n</p>\n";
echo "
<div>
easy formatting<br />
across multiple lines!
</div>
";
?>
<p>hello
world</p>
<p>
indented
</p>
<div>
easy formatting<br />
across multiple lines!
</div>
Like this:
str_repeat(' ', 5); // adds 5 spaces
To render more than one whitespace on most web browsers use
instead of normal white spaces.
echo "<p>Hello punt"; // This will render as Hello Punt (with 4 white spaces)
echo "<p> Hello punt"; // This will render as Hello punt (with one space)
For showing data in raw format (with exact number of spaces and "enters") use HTML <pre>
tag.
echo "<pre>Hello punt</pre>"; //Will render exactly as written here (8 white spaces)
Or you can use some CSS to style current block, not to break text or strip spaces (dunno bout this one)
Any way you do the output will be the same but the browser itself strips double white spaces and renders as one.
PHP
is an easy language with multiple solutions. A Quick Solution would be using Double Quotes " "
. Example Below.
$var1 = "Hello";
$var2 = "World";
$var3 = "How";
$var4 = "are";
$var5 = "you";
$var6 = "?";
$var7 = ",";
echo "$var1 $var2$var7 $var3 $var4 $var5$var6";
//Output: Hello World, How are you?