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?

11 of 12 people (92%) answered Yes
Recently 9 of 10 people (90%) 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, Ilya Poropudas, ssp2000 ssp2000,


I'm not quite sure what you mean.
If you're adding two numerical values:
    $sum = $var1 + $var2;
If you want to concatenate two strings:
    $newstring = $str1 . $str2;
Adding a separating character between the two strings is simple:
    $newstring = $str1 . ":" . $str2;
If you later need to split the two values, just use explode():
http://www.php.net/manual/en/function.explode.php
    $values_array = explode(":", $newstring);
    $str1 = $values_array[0];
    $str2 = $values_array[1];
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