var person = {
address: [
'308 Congress Street',
'Boston',
'Massachusetts'
]
}
如何在"address"
中插入数组连接方法并显示所有数组项。
结果如下:308 Congress Street, Boston, Massachusetts
答案 0 :(得分:1)
使用像这样的加入
person.address.join(',')
答案 1 :(得分:0)
答案 2 :(得分:0)
如果您希望 Schema::create('carts', function (Blueprint $table) {
$table->increments('id');
$table->integer('product_id')->unsigned();
$table->integer('product_choice_id')->unsigned();
$table->integer('user_id')->unsigned();
$table->integer('shop_id')->unsigned();
$table->integer('qty');
$table->integer('complete')->default(0);
$table->timestamps();
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade')
->onUpdate('cascade');
$table->foreign('product_id')
->references('id')
->on('products')
->onDelete('cascade')
->onUpdate('cascade');
$table->foreign('shop_id')
->references('id')
->on('shops')
->onDelete('cascade')
->onUpdate('cascade');
$table->foreign('product_choice_id')
->references('id')
->on('product_choice')
->onDelete('cascade')
->onUpdate('cascade');
});
数组的最后一个索引为组合值,只需执行...
address
答案 3 :(得分:0)
像这样......使用数组' join()
方法。join()
方法将所有数组元素连接成一个字符串。
var person = {
address: [
'308 Congress Street',
'Boston',
'Massachusetts'
]
}
alert(person.address.join(', '));//OR alert(person['address'].join(', '));