PHP 7.1.21 Released

join

(PHP 4, PHP 5, PHP 7)

joinAlias of implode()

Description

This function is an alias of: implode().

add a note add a note

User Contributed Notes 3 notes

up
9
A.Rafay Hingoro
3 years ago
<?php
   
//first example
   
$array = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10');   
    echo
join('<br>', $array);
   
   
//first example (result)
    /*
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    */
   
    //second example
   
$arr[] = '1a';
   
$arr[] = '2b';
   
$arr[] = '3c';
   
$arr[] = '4d';
   
$arr[] = '5e';
   
$arr[] = '6f';
   
$arr[] = '7g';
   
$arr[] = '8h';
   
$arr[] = '9i';
   
$arr[] = '10j';
   
    echo
join('<br>', $arr);
   
//second example (result)
    /*
    1a
    2b
    3c
    4d
    5e
    6f
    7g
    8h
    9i
    10j
    */
up
2
aayush dot aryan7 at gmail dot com
4 months ago
The join function will operate only on values and not keys, if you want to include keys then need to manipulate the array to have keys data in the Value itself...

What I mean:

$array = array(
   'red' => 'APPLE',
   'yellow' => 'BANANA',
   'orange' => 'ORANGE'
  );

echo (join(", ", $array));

Will output: APPLE, BANANA, ORANGE

That does not contain the key information...
up
-17
erdalceylan25 at gmail dot com
7 months ago
$instance = \ArrayJoin\Builder::newInstance()
     ->select("a.id", "a.nick", "b.item")
     ->from($users, "a")
     ->innerJoin($items, "b", new \ArrayJoin\On("a.id = b.user_id"))
     ->setFetchType(\ArrayJoin\Builder::FETCH_TYPE_ARRAY)
     ->offset(1)
     ->limit(2);
    
$instance->execute();

https://github.com/erdalceylan/array-join
To Top