PHP 中是否有任何数组函数可以实现此目的:
// get all the user ids as comma seprated.
$users = array();
foreach($view as $result)
{
$users[] = $result->uid;
}
$uid = implode(',', $users);
示例:
$array[0] = array("size" => "XL", "color" => "gold");
$array[1] = array("size" => "XLL", "color" => "siver");
$array[2] = array("size" => "M", "color" => "purple");
我需要
$color = "gold,silver,purple";
您可以使用explode(',', $view)来获取值数组。
根据您更新的问题:
你可以尝试这样的事情:
'名字_值','姓氏'=>'姓氏_值'); sprintf('插入 %s (%s) 值 ("%s")', 'table_name', implode(', ', array_map('mysql_escape_string', array_keys($values))), implode('", " ',array_map('mysql_escape_string', $values))); //这给你: INSERT INTO table_name (firstname, lastname) VALUES ("firstname_value", "lastname_value") ?>