遍歷二維數組
<code><span><span><span><?php</span><span>$arr</span>=<span>array</span>( <span>array</span>(<span>"Volvo"</span>,<span>22</span>,<span>18</span>), <span>array</span>(<span>"BMW"</span>,<span>15</span>,<span>13</span>), <span>array</span>(<span>"Saab"</span>,<span>5</span>,<span>2</span>), <span>array</span>(<span>"Land Rover"</span>,<span>17</span>,<span>15</span>) ); <span>echo</span><span>"<table><tr><td>汽车品牌</td><td>库存</td><td>销量</td></tr>"</span>; <span>for</span> (<span>$i</span>=<span>0</span>;<span>$i</span><count(<span>$arr</span>);<span>$i</span>++){ <span>echo</span><span>"<tr>"</span>; <span>for</span>(<span>$j</span>=<span>0</span>;<span>$j</span><count(<span>$arr</span>[<span>$i</span>]);<span>$j</span>++){ <span>echo</span><span>"<td>"</span>.<span>$arr</span>[<span>$i</span>][<span>$j</span>].<span>"</td>"</span>; } <span>echo</span><span>"</tr>"</span>; } <span>echo</span><span>"</table>"</span>; <span>?></span></span></span></code>
日期和時間函數date()
日期和時間在PHP中以時間戳的形式存儲,透過date()函數處理才能轉換為易讀的模式
語法:date(格式,時間戳);省略第二個參數預設為當前時間
格式分類:
輸出當前日期:
<code><span><span><span><?php</span><span>echo</span> date(<span>'Y-d-m h:i:s'</span>).<span>"<br/>"</span>; ehco date(<span>'Y.d.m h:i:s'</span>).<span>"<br/>"</span>; <span>echo</span> date(<span>'Y/d/m h:i:s'</span>).<span>"<br/>"</span>; <span>?></span></span></span></code>
<code><span><span><?php</span> ehco <span>'现在的时间是:'</span>.date(<span>'h:i:sa'</span>); <span>?></span></span></code>
').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介紹了PHP多維數組和日期時間函數,包括了PHP多維數組,日期時間方面的內容,希望對PHP教程有興趣的朋友有所幫助。
🎜 🎜