Jump to content

Recommended Posts

Hi,

Welcome <?php echo $_GET["firstname"]; ?>.<br />
Name<?php echo $_GET["Lastname"]; ?>.<br />
You are <?php echo $_GET["numer"]; ?> 

 

The result is below.

 

Welcome name .

Name chinna .

You are 45

 

There is space after every echo result.

how do i stop that space from generating.

 

Thank you

 

Link to comment
https://forums.phpfreaks.com/topic/207906-delete-the-space-created-after-echo/
Share on other sites

http://domain.com/flash/welcome.php?firstname=name+&Lastname=chinna+&numer=2336+

 

Just realize that space come from + sign on my URL

 

still looking for a way to delete it

 

Not that space.

 

what i mean is

on my example there are space after echo result.

 

name(space).

chinna(space).

45(space).

str_replace is a handy function.

 

$myVar = "One Space Two Space Three Space Four";

 

$x = str_replace(" ","",$myVar);

 

$x will output:

 

"OneSpaceTwoSpaceThreeSpaceFour"

 

Beware though, although there is a way, i havent managed to get it work nicely with words.  for instance:

 

$myVar = "I like to read the manual, man";

 

$x= str_replace("man","dude",$myVar);

 

$x = "I like to read the dudeual, dude".

 

There is a way but i couldnt be bothered to look into it at the time.

:)

 

hope that helps.

$myVar = "One Space Two Space Three Space Four";

 

is there is a way to change

One Space Two Space Three Space Four

to

echo $_GET["fullname"];

 

coz thats how i get the full name of the user

 

 

 

str_replace is a handy function.

 

$myVar = "One Space Two Space Three Space Four";

 

$x = str_replace(" ","",$myVar);

 

$x will output:

 

"OneSpaceTwoSpaceThreeSpaceFour"

 

Beware though, although there is a way, i havent managed to get it work nicely with words.  for instance:

 

$myVar = "I like to read the manual, man";

 

$x= str_replace("man","dude",$myVar);

 

$x = "I like to read the dudeual, dude".

 

There is a way but i couldnt be bothered to look into it at the time.

:)

 

hope that helps.

chud37, you'd use regular expressions in preg_replace() function to perform that task. I'm not all too good with regular expressions but this will work to find all instances of "man" with a space either side. '\s' denotes a space while '/' signifies the search string

i'm sure someone else could help to change the search expression so it searched for "man" with no alphabetic character next to it.

$myVar = "I like to read the manual, man";

$search = array("/\sman\s/");
$replace = array("dude");

$myVar = preg_replace($search, $replace, $myVar);

 

and markcunningham07,

you want to change $myVar to $_GET['fullname'] and remove spaces in it?!

i.e. $x = str_replace(" ","",$_GET['fullname']);

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.