UGN Security Forums
My ProfileMember DirectoryLogin
Search our ForumsView our FAQView our Site Rules
View our CalendarView our Active TopicsGo to our Main Page

UGN Security Store
 

Network Sites UGN Security, The GoNix Initiative, Elite Web Gamers, Back of the Web, EveryDay Helper, VNC Web Design & Development
September
Su M Tu W Th F Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Sponsored Links
Latest Postings
Doom 3
by Cyrez
09/11/14 08:58 PM
The History Thread...
by Cyrez
09/11/14 08:56 PM
Amazon Gift Card Generator/KeyGen?te
by Gecko666
08/22/14 09:21 AM
Latest Reviews
Topic Options
Rate This Topic
#18422 - 01/14/03 02:22 PM PHP- Stitching together strings
Cold Sunn Offline
UGN GFX Whore

Registered: 03/03/02
Posts: 574
Loc: us
I've asked a few people, but I don't know what this is called, so it is kind of hard to search for it. What I want to do, is something like...

Let's say $one is "Roger Man" and $two is "Johnny Boy." I want to make $result "Roger ManJohnny Boy."

Anyone know how to do it in php? While I am at it...

Anyone know how to or what it is called when you make take "1" and make it "01" or "001"? They are all equal to each other mathematically but different as strings. I could do it with an IF ELSEIF thing and the stitching thing if I only knew how. :\

Top
Sponsored Links
      
#18423 - 01/15/03 07:17 AM Re: PHP- Stitching together strings
SilentRage Offline
DollarDNS Owner

Registered: 03/04/02
Posts: 1273
Loc: OH, USA
"stitching together stings" is called concatenation

This is the way you can do it in perl:

$result = $one . $two;

Since PHP and perl are much alike, try it, it may work.
_________________________
Domain Registration, Hosting, Management
http://www.dollardns.net

Top
#18424 - 01/15/03 01:26 PM Re: PHP- Stitching together strings
pergesu Offline
UGN Elite Poster

Registered: 03/14/02
Posts: 1136
Loc: Pimpin the Colorizzle
There are two way, one is what SR said. Another way is to put it in a string itself. When PHP sees double quotes, it evaluates everything inside the quotes. So you can do:
$result = "$one$two";

Because it evaluates what's in the quotes, you can incorporate variable values into strings. So you can have:
$result = "I saw $one and $two the other day.";
echo $result;

That will print out:
I saw Roger Man and Johnny Boy the other day.

If you use single quotes, it doesn't evaluate it. So if you have the code:
$result = 'I saw $one and $two the other day.';
echo $result;

It will print out:
I saw $one and $two the other day.

So you have an easy way of incorporating variables into strings. The other way is to use SR's way, so it would look like:
$result = "I saw " . $one . " and " . $two . " the other day.";

Either of em works, it's just your personal preference. I mix and match, depends on how I'm using the variables. Sometimes it looks cleaner to use the . method, but sometimes I want to show that the variable value is a central part of the string. Your preference

Top
#18425 - 01/15/03 02:00 PM Re: PHP- Stitching together strings
Cold Sunn Offline
UGN GFX Whore

Registered: 03/03/02
Posts: 574
Loc: us
perg- after reading that I think it should have been obvious.

I can't believe I didn't see it, I've used the same method before but not for what I want to use it for.

Thanks SR and Perg.

Top
#18426 - 01/15/03 02:28 PM Re: PHP- Stitching together strings
SilentRage Offline
DollarDNS Owner

Registered: 03/04/02
Posts: 1273
Loc: OH, USA
yeah, in perl you can do it how pergesu suggested. I just shied away from bunching 2 vars up against each other, so I didn't mention it. It probably is fine though.
_________________________
Domain Registration, Hosting, Management
http://www.dollardns.net

Top

Moderator:  §intå×, Gremelin 
Featured Member
Registered: 08/22/14
Posts: 1
Forum Stats
2148 Members
46 Forums
34395 Topics
69564 Posts

Max Online: 1567 @ 04/25/10 02:20 AM
Top Posters
UGN Security 27557
Gremelin 7192
§intå× 3255
SilentRage 1273
Ice 1146
pergesu 1136
Infinite 1041
jonconley 955
Girlie 908
unreal 860
Newest Members
Gecko666, defghi795767, Devo60, ali, lavos
2147 Registered Users
Who's Online
0 registered (), 110 Guests and 159 Spiders online.
Key: Admin, Global Mod, Mod
Latest News


Donate
  Get Firefox!
Get FireFox!