我有一个包含子目录的目录,在每个子目录中都有图像。我想随机显示图像。在我在 php 中运行良好的代码下方,但它在 Laravel 中不起作用,问题出在opendir()和readdir()。
查看刀片
<?php
$folder = opendir('images/');
$i = 0;
while(false !=($file = readdir($folder))){
if($file != "." && $file != ".."){
$images[$i]= $file;
$i++;
}
}
$random_img=rand(0,count($images)-1);
?>
<div>
<?php
echo '<img src="images/'.$images[$random_img].'" alt="" />';
?>
</div>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Google图表API,但是我收到一个我无法理解的错误:
TypeError:google.charts.Bar不是构造函数
这是我的代码:
<div class="row">
<div class="col-md-12" style="padding-left:3px; padding-right:3px">
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Date', 'val1', 'val2' , 'val3', 'val4'],
[ '09', 12, 5, 9, 2],
[ '10', 32, 19, 16, 9],
[ '11', 2, 7, 5, 12],
[ '12', 23, 11, 9, 18],
[ '13', 5, 7, 4, 12],
[ '14', 21, 16, 12, 43],
[ '15', 2, 1, 2, 3],
[ '16', 9, …Run Code Online (Sandbox Code Playgroud) 我试图从表中获得多个where和/或子句的结果.但我没有收到好成绩!
$queries = journal::where(function($query)
{
$term =Input::get('text');
$query->where('titre', 'like', '%'.$term.'%')
->where('etat','!=','9')
->where('type', 0)
->orWhere('type', 1);
})->take(10)->get();
Run Code Online (Sandbox Code Playgroud)