PHP 7.0.6 Released

join

(PHP 4, PHP 5, PHP 7)

joinAlias of implode()

Description

This function is an alias of: implode().

User Contributed Notes

A.Rafay Hingoro
8 months 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
    */
fardinf2r at gmail dot com
7 months ago
class example{
public function create(){
        global $database;
        $attributes  = $this->get_object_vars($this);
        $sql  = "INSERT INTO ". self::$table_name ." (";
        $sql .= join(", ",array_keys($attributes));
        $sql .= ") VALUES ('";
        $sql .= join("', '", array_values($attributes));
        $sql .= "')";
        if($database->query($sql)){
            $this->id = $database->insert_id();
            return true;   
        }else{
            return false;
        }
    }
}
To Top