如何使用PHP将其作为一个数组?
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
# user - title - img - content - Created
class Post(models.Model) :
user = models.ForeignKey(User )
title = models.CharField(max_length=50)
content = models.TextField(default=' ')
img = models.ImageField(upload_to= 'post_img/')
Created = models.DateTimeField()
def __str__(self):
return self.title
我要像这样将这些数组组合成一个数组
["08:00 AM","08:15 AM","08:30 AM","08:45 AM"]
["09:00 AM","09:15 AM","09:30 AM","09:45 AM"]
["10:00 AM","10:15 AM","10:30 AM","10:45 AM"]
["11:00 AM","11:15 AM","11:30 AM","11:45 AM"]
["04:00 PM","04:15 PM","04:30 PM","04:45 PM"]
["05:00 PM","05:15 PM","05:30 PM","05:45 PM"]
["06:00 PM","06:15 PM","06:30 PM","06:45 PM"]
答案 0 :(得分:4)
您使用variadic functions operator的...
运算符(PHP 5.6及更高版本array-merge):
$arr = array(["aaa", "bbb"],["ccc","ddd"]);
$arr = array_merge(...$arr);
答案 1 :(得分:1)
使用内置的全局array_merge()
函数。