我获取值表单日期范围并使用explode到数组错误行whereBetween
$range = Input::get('daterange') ;
$date = explode('to', $range);
//dd($date);
$temp = Temps::select('temp')
->orderBy('date_temp', 'asc')
->whereBetween('date_temp',[$date[0], $date[1]])
->get()
->pluck('temp');
1/1)ErrorException未定义的偏移量:1
答案 0 :(得分:0)
您需要更改,因为范围为$range='09/11/2017 - 10/10/2017';
。您需要使用-
进行拆分
$date = explode('-', $range);
如果您打印$date
Array
(
[0] => 09/11/2017
[1] => 10/10/2017
)
另请注意,您可以直接传递数据。由于[$date[0], $date[1]
接受数组而且whereBetween
是数组
$date
而不是$temp = Temps::select('temp')
->orderBy('date_temp', 'asc')
->whereBetween('date_temp',$date)
->get()
->pluck('temp');
def ip_matches_network(self, network, ip):
"""
'{:08b}'.format(254): Converts 254 in a string of its binary representation
ip_bits[:net_mask] == net_ip_bits[:net_mask]: compare the ip bit streams
:param network: string like '192.168.33.0/24'
:param ip: string like '192.168.33.1'
:return: if ip matches network
"""
net_ip, net_mask = network.split('/')
net_mask = int(net_mask)
ip_bits = ''.join('{:08b}'.format(int(x)) for x in ip.split('.'))
net_ip_bits = ''.join('{:08b}'.format(int(x)) for x in net_ip.split('.'))
# example: net_mask=24 -> compare strings at position 0 to 23
return ip_bits[:net_mask] == net_ip_bits[:net_mask]
答案 1 :(得分:0)
试试这个:
$date = explode('-', $range);
您试图使用变量中不存在的字符串来展开变量,这就是为什么在$date