dismiss Step into the future! Click here to switch to the beta php.net site
downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

lcfirst> <implode
[edit] Last updated: Fri, 28 Jun 2013

view this page in

join

(PHP 4, PHP 5)

joinAlias of implode()

Description

This function is an alias of: implode().



add a note add a note User Contributed Notes join - [2 notes]
up
2
meathanjay at gmail dot com
1 month ago
<?php
//Join same as implode()
$arr=array("First","Second","Third","Four","....+N");
echo
join(" ",$arr);
up
-2
datacompboy at call2ru dot com
4 years ago
Very useful function i have using: joinr (join-recursive).
It allows you easy join of multi-level arrays.
For example, if you have
  $intervals = array(array(5, 9), array(11, 15), array(22, 24))
and want to have comma-separated list of dash-separated intervals, just do
  print joinr(array(",","-"), $intervals);

Here is function code:
<?php
   
function joinr($join, $value, $lvl=0)
    {
        if (!
is_array($join)) return joinr(array($join), $value, $lvl);
       
$res = array();
        if (
is_array($value)&&sizeof($value)&&is_array(current($value))) { // Is value are array of sub-arrays?
           
foreach($value as $val)
               
$res[] = joinr($join, $val, $lvl+1);
        }
        elseif(
is_array($value)) {
           
$res = $value;
        }
        else
$res[] = $value;
        return
join(isset($join[$lvl])?$join[$lvl]:"", $res);
    }
?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites