Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Combine two strings

string

  • Please log in to reply
6 replies to this topic

#1 Chan

Chan

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 202 posts

Posted 18 September 2006 - 03:18 PM

In PHP how can I combine two strings like


$myString = "Hey";
$myString += " you";


The above doesn't seem to work.
  • 0

#2 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 19 September 2006 - 05:23 AM

I dont know but perhaps this will do:-

$first = 'Hey';
$last = ' you';
$full  = $first . ' ' . $last;

  • 0

#3 Lop

Lop

    Speaks fluent binary

  • Just Joined
  • PipPipPipPipPipPipPip
  • 1112 posts

Posted 19 September 2006 - 10:21 AM

Yes, use a dot instead of the +


$myString = "Hey";
$myString = $myString . " you";


Not sure if this works, never tried:


$myString = "Hey";
$myString .= " you";


but I doubt it.
  • 0

#4 John

John

    CC Mentor

  • Moderator
  • 4450 posts
  • Location:New York, NY

Posted 23 September 2006 - 10:29 PM

what about array_push()

edit: i wasnt fully coherant when i posted this...but the above is if you want to combined two arrays, not strings
  • 0

#5 Guest_CheeseBurgerMan_*

Guest_CheeseBurgerMan_*
  • Guest

Posted 24 September 2006 - 05:55 AM

I believe you can do that with the echo command

echo $myString + "another string";

EDIT: Oops, I completely misread that question. Ignore this post. :P
  • 0

#6 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 24 September 2006 - 06:55 AM

I believe you can do that with the echo command

echo $myString + "another string";

EDIT: Oops, I completely misread that question. Ignore this post. :P


So y not deleting your post? just go to Edit and press delete!
  • 0

#7 Chan

Chan

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 202 posts

Posted 29 September 2006 - 03:02 PM

The . works - I figured it out after I posted this. Sorry for not updating and thanks
  • 0





Also tagged with one or more of these keywords: string

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download