php數組入門教程之數組的指標操作

來源:互聯網
上載者:User
本文介紹下,有關php數組中數組指標的相關內容,有需要的朋友參考下。

在php中,涉及數組指標的函數有:reset、prev、end、next、current、each。

例1,next 與 prev

";echo prev($speed);//輸出前一位置數組值echo "
";echo reset($speed);//重設數組的指標,將指標指向起始位置echo "
";echo end($speed);//輸出最後位置的數組值echo "
";//by bbs.it-home.org?>

運行結果:02202000220

例2,each函數指標操作

";echo "0擋的速度是".current(each($speed))."
";echo "1擋的速度是".current(each($speed))."
";echo "2擋的速度是".current(each($speed))."
";echo "3擋的速度是".current(each($speed))."
";echo "4擋的速度是".current(each($speed))."
";echo "5擋的速度是".current(each($speed))."
";echo "使用each函數實現數組指標的移動,進行數組遍曆
";reset($speed);//這裡是將數組指標指向數組首while(list($key,$value)=each($speed)){echo $key."=>".$value."
";}?>

運行結果:each實現指標下移0擋的速度是01擋的速度是402擋的速度是803擋的速度是1204擋的速度是1605擋的速度是200使用each函數實現數組指標的移動,進行數組遍曆0=>01=>402=>803=>1204=>1605=>200

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.