PHP string concatenation

String concatenation is the string manipulation method when you join 2 or more strings together.

In PHP it is a quite easy task. You can use the concatenation operator which is the ‘.’ (dot). You can join 2 or more strings into one as follows:

   $str1 = 'This';
   $str2 = 'is a';
   $str3 = 'string';
 
   $full = $str1.' '.$str2.' '.$str3;
 
   echo $full; // This is a string

Besides this you can use the operator to append a string to an existing one like this:

   $str  = 'Main string';
   $str .= ' plus another string';
 
   echo $str; // Main string plus another string

If you concatenate a string with a number, the number will (automatically) be converted into a string value, so the output will be “string”:

   $num = 100;
   $str = $num.' is a number';
 
   echo $str; // 100 is a number
No CommentsPermalink

Get age from birth date

ShareA PHP function to calculate the age of a person by passing in their birth date in standard format.

No CommentsRead this post »

Multiple columns with WP’s: wp_post_page()

Share
Creating a multi-column list from Wordpress’ default function (wp_post_page()) is a pain.
I was tasked to create a multi-column list and realized there wasn’t a simple argument to do so.
With that said, I have to create a code which should do the job…and it does the job so well.

/////// Configure this part for the number of [...]

3 CommentsRead this post »
Get Adobe Flash playerPlugin by wpburn.com wordpress themes