©
本文档使用 PHP中文网手册 发布
(PHP 4, PHP 5)
join — 别名 implode()
此函数是该函数的别名: implode() .
[#1] fardinf2r at gmail dot com [2015-09-21 12:13:48]
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;
}
}
}
[#2] A.Rafay Hingoro [2015-08-04 20:36:48]
<?php
//first example
$array = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10');
echo join('<br>', $array);
//first example (result)
//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)