<?php
$arr = [23,3,45,6,78,8,34];
function getarr()
{
$newarr=array();
$i=0;
global $arr;
foreach($arr as $arrs)
{
if($arrs%2==0):
$newarr[$i]=$arrs;
$i++;
endif;
}
return $newarr;
};
echo '<pre>';
print_r(getarr()) ;
博客列表 >16期8月5日作业
<?php
$arr = [23,3,45,6,78,8,34];
function getarr()
{
$newarr=array();
$i=0;
global $arr;
foreach($arr as $arrs)
{
if($arrs%2==0):
$newarr[$i]=$arrs;
$i++;
endif;
}
return $newarr;
};
echo '<pre>';
print_r(getarr()) ;