PHP 進度條函數(shù)的簡單實例
更新時間:2017年09月19日 16:19:12 作者:用戶昵稱不能為空
這篇文章主要介紹了PHP 進度條函數(shù)的簡單實例的相關(guān)資料,希望通過本文能幫助到大家,需要的朋友可以參考下
PHP 進度條函數(shù)的簡單實例
其實進度條的做法很簡單的。網(wǎng)上的一大堆,自己寫了一個,哈哈,感覺看起來很有感覺。
實例代碼:
function ShowPercent($now,$total) { $percent = sprintf('%.0f',$now*100/$total); $html = '<table width="60%" style="border-collapse:separate" height="10" border="0" cellpadding="0" cellspacing="2" bgcolor="#fff"><tr>'; $count=0; $pertr = 30; while($count < $total) { $bgcolor = $count < $now ? 'green':'#EEEEEE'; $html .= '<td bgcolor="'.$bgcolor.'"> </td>'; $count++; if($count%$pertr == 0) $html .= '</tr><tr>'; } $bgcolor2 = $now == $total ? ' style="font-weight:bold;color:green;"':''; $html .= '<td'.$bgcolor2.' colspan="'.($count%$pertr).'">'.$percent.'%</td></tr></table>'; return $html; }
效果截圖: 100%的時候。
如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
Laravel框架中隊列和工作(Queues、Jobs)操作實例詳解
這篇文章主要介紹了Laravel框架中隊列和工作(Queues、Jobs)操作實例詳解,需要的朋友可以參考下2020-04-04php5.3/5.4/5.5/5.6/7常見新增特性匯總整理
這篇文章主要介紹了php5.3/5.4/5.5/5.6/7常見新增特性,整理總結(jié)了php5.3/5.4/5.5/5.6/7各種常見的新增特性,包括各種語法、關(guān)鍵字、函數(shù)、擴展等,需要的朋友可以參考下2020-02-02php使用unset()刪除數(shù)組中某個單元(鍵)的方法
這篇文章主要介紹了php使用unset()刪除數(shù)組中某個單元(鍵)的方法,實例分析了unset函數(shù)在刪除數(shù)組單元時的使用技巧,需要的朋友可以參考下2015-02-02