How can I add space in PHP between two outputs
use the below code
<?php
echo 'Welcome '.$_GET['name'];
?>
is the html entity code for creating an single space character.
You can also use the below code:
<?php
echo 'Welcome '.$_GET['name'];
?>
Will also work because one empty space is interpreted by the browsers directly.
How can I add spaces in PHP?
I assume that you're echoing this to a browser, in which case, & nbsp;
must be used.
echo $row['st_id'], " " , $row['em_name'], " ", $row['st_bday'], "", $row['st_emirate'] , "", $row['em_id'], " ", $row['em_name'],'<br />';
PHP echo add spaces
A better way would be not to add more spaces, but add a margin:
<span class="white-text" style="margin-right: 5em;">
Change 5em
to some other number to change the amount of space.
PHP adds a space when echo
I could reproduce your issue...
The thing is, when you have double quotes on a quoted attribute, it seems to do that.
<a class="over" onclick="update(" bv", "code", "yes")">Beverwijk</a>
^--bad--^
Solution: use single quotes on the function parameters, escaping them.
$route = '<a class="over" onclick="update(\''.$info->getData("code").'\', \'code\' \'yes\')">'.$expl[$b].'</a>, ';
Result:
<a class="over" onclick="update('BV', 'code' 'yes')">Beverwijk</a>,
Hope this helps.
add space in html when using php echo
<?php
echo "$itemName value2";
?>
If you use double quotes, you can drop the variable right in there, no concatenation needed!
<article id="portfolio-item-1" data-loader="include/ajax/portfolio-ajax-image.php" class="<?php echo "$itemName value2"; ?>">
How to add space with specified string length in php
I did with my self with following way..
<?php
echo str_pad($string, 30, "  ", STR_PAD_RIGHT).$secondString;
?>
How do i add space between this php variables
You're generating invalid HTML. This:
'<option value='. $spName . ' ' . $spPro .'>'
^--- WITH the added space
Will produce something like this:
<option value=SomeName SomeProfession>
The browser has no way of knowing that these two values are part of the same attribute. In short, you forgot the quotes. You want to generate something like this:
<option value="SomeName SomeProfession">
So put the quotes in your code:
'<option value="'. $spName . ' ' . $spPro .'">'
In short, always look at the actual HTML that's in your web browser when debugging this. Don't just look at what ends up in the database somewhere downstream in the system, but look at the actual steps which lead to that downstream result. Invalid HTML is often fairly obvious to see when you look at the HTML itself.
Related Topics
How to Change Value of Select Options Based on Another Select Option Selected
Regex to Check the String Contains Only Letter and Numbers But Not Only Numbers
How to Change PHP Version in Xampp
How to Delete Multiple Redis Keys With the Same Pattern in PHP Using Phpredis
How to Get Next Id of Autogenerated Field in Laravel for Specific Table
Regex - Exclude "-" Between Numbers
Creating Advanced Search Query With PHP Mysqli
Laravel 5.5 Error 500 in Cpanel Shared Hosting
Getting Check Box Values as Checked from Database Codeigniter
Group Array Data on One Column and Sum Data from Another Column
How to Convert Jquery Ajax Success Data to a PHP Variable
Auto Update Cart on Click in Woocommerce
SQL Injection That Gets Around mysql_real_escape_string()
How to Convert Ereg Expressions to Preg in PHP
MySQLi or Pdo - What Are the Pros and Cons