我想将偶数添加到数组然后回显它,这是我的代码,但是当我打印时它只显示array()...我做错了什么?
<script>
x= get date
if (date <= showbefore & >= showafter){show div}
<html>
<div 1 showbefore = a showafter = b> !-- advert for valentines
<div 1 showbefore = a showafter = c> !-- advert for mothers day
<div 1 showbefore = d showafter = f> !-- advert for easter sunday
<div 1 showbefore = h showafter = x> !-- advert for christmas.
答案 0 :(得分:3)
您应该从while
循环移动“均匀度”测试,并将其移至while
循环中的条件:
<?php
$x = 88;
$numbers = array();
while ($x <= 99) {
if ($x % 2 == 0) {
$numbers[] = $x;
}
$x++;
}
print_r($numbers);
?>
正如您当前编写的while
循环一样,如果数字不均匀则结束。您还应该在添加到$x
数组时从$numbers
删除引号。