Correction status:qualified
Teacher's comments:
//编程1: 实例演示substr(),strstr(),strpos()函数
//编程2: 实例演示str_replace(), substr_replace()
//编程3: 实例演示: usort()二维数组的排序
<?php //编程1: 实例演示substr(),strstr(),strpos()函数 //编程2: 实例演示str_replace(), substr_replace() //编程3: 实例演示: usort()二维数组的排序 $STRING='PHP\HTML\CSS'; echo substr($STRING,0,4),'<br>'; echo substr($STRING,4),'<br>'; echo substr($STRING,-3),'<br>'; echo '<hr>'; echo strstr($STRING,'html'),'<br>'; echo strstr($STRING,'HTML'),'<br>'; echo strstr($STRING,'HTML',true),'<br>'; echo strstr($STRING,'HTML',false),'<br>'; echo '<hr>'; echo strpos($STRING,'HTML'),'<br>'; echo substr($STRING,strpos($STRING,'HTML'),strlen('HTML')); echo '<hr>'; echo substr_replace($STRING,'H5',4,4),'<br>'; echo substr_replace($STRING,'H5',4,0),'<br>'; echo '<hr>'; echo str_replace('HTML','H5',$STRING,$count),'<br>'; echo '替换了',$count,'次'; echo '<hr>'; $nba=[ ['team'=>'勇士','win_num'=>40], ['team'=>'火箭','win_num'=>50], ['team'=>'骑士','win_num'=>50], ['team'=>'湖人','win_num'=>60]]; usort($nba,function ($a,$b){ if($a['win_num']=$b['win_num']){ return 0; }else { return $a['win_num'] > $b['win_num'] ? 1 : -1; } }); echo var_export($nba,true);
点击 "运行实例" 按钮查看在线实例