faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 5 people (100%) answered Yes
Recently 5 of 5 people (100%) answered Yes

Entry

How can i join two values to form a single value by using a seprator character?

Mar 15th, 2008 17:58
ha mo, Philip Olson, ssp2000 ssp2000,


By using simple string concatenation, for example:
  $a = 'apple';
  $b = 'banana';
  $c = $a . ':' . $b;
  echo $c; // apple:banana
Or create your own function to do the same:
  function concat_mystrings($str1, $str2, $glue = ':') {
      return $str1 . $glue . $str2;
  }
  echo concat_mystrings('a','b');
Also see the manual page on string operators:
  String Operators:
  -------------------------------------------------------------------
  http://www.php.net/manual/en/language.operators.string.php
http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.mozmar.com
http://www.yamot.com
http://www.templatestemp.com