promotion image of download ymail app
Promoted
asked in 電腦與網際網路程式設計 · 1 decade ago

array的用法有哪些?功能是什麼?

array_splice、array_slice等等的

還有哪些array的用法

比如說array_splice($a,$b,$c)他代表的涵義是怎樣的

謝謝~

這兩個array_splice、array_slice 也要說明~感恩

1 Answer

Rating
  • ?
    Lv 4
    1 decade ago
    Favorite Answer

    PHP手冊就有所有的Array Functions,可以看看。

    http://tw2.php.net/manual/en/ref.array.php

    -----

    array_splice是移除或取代陣列中的元素

    array_splice ( array &$input , int $offset [, int $length [, mixed $replacement ]] )

    例如:array_splice

    $colors = array("red", "green", "blue", "yellow");

    array_splice($colors, 2);

    // $colors 會變成("red", "green")

    ---

    array_slice是取出陣列中某幾個元素

    array_slice ( array $array , int $offset [, int $length [, bool $preserve_keys ]] )

    例如:$chars = array("a", "b", "c", "d", "e");

    $chars_slice = array_slice($chars, 2);

    // $chars_slice會變成 ("c","d","e");

    $chars_slice = array_slice($chars, 0, 3);

    // $chars_slice會變成 ("c","b","c");

    Source(s): Myself & www.php.net
    • Commenter avatarLogin to reply the answers
Still have questions? Get your answers by asking now.