Posted By

mscribellito on 11/19/10


Tagged

concatenation concatenate


Versions (?)

String Concatenator


 / Published in: PHP
 

Used to concatenate any given number of arguments into a single string. An alternative to the ugly: $somevar . $anothervar or sprintf("%s %s", $somevar, $anothervar)

  1. /**
  2.  * Generate HTML Tag
  3.  *
  4.  * @param string text
  5.  * @return string concatenated string
  6.  */
  7. function concat() {
  8. for ($args = func_get_args(), $str = '', $i = 0; $i < count($args); $i++) {
  9. $str .= $args[$i];
  10. }
  11. return $str;
  12. }

Report this snippet  

You need to login to post a comment.