Correction status:qualified
Teacher's comments:实例中的PHP标签都没带哦
代码作业:
$heros = []; //声明一个空数组,后面的值通过追加的方式,添加进去 $heros['name'] = 'ooo'; $heros['title'] = 'ooooooooo'; $heros['advantages'] = 'zzzz'; //echo '<pre>' .print_r($heros, true); // 遍历数组 $res1 = ''; for( $i=0; $i<count($arts); $i++){ // print_r( $arts[$i] ); $res1 .= $arts[$i] . ','; } echo $res1; echo '<hr/>'; echo rtrim( $res1, ',' ); //删除右侧指定字符 //数组回调 $arr3 = ['html', 'css', 'javascript']; $arr4 = array_filter($arr3, function($value){ return $value !== 'css'; }); echo var_export($arr4); compact() 将变量转为数组 $name= 'xxx'; $factory= 'fffff'; $position= 'ppp'; $arr2 = compact('name','factory','position'); echo var_export($arr2, true); //将字符串转为数组 explode() $lang = 'html,css,javascript,jquery'; echo '<pre>' . var_export(explode(',', $lang)) . '</pre>';
点击 "运行实例" 按钮查看在线实例