<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # [ArrayObject](https://www.php.net/manual/zh/class.arrayobject.php "ArrayObject") >[info] ArrayObject是將數組轉換為數組對象 ``` ArrayObject implements IteratorAggregate , ArrayAccess , Serializable , Countable { /* 常量 */ const integer STD_PROP_LIST = 1 ; const integer ARRAY_AS_PROPS = 2 ; /* 方法 */ //IteratorAggregate(聚合式迭代器)接口 public getIterator ( void ) : ArrayIterator //獲取一個外部迭代器 從ArrayObject實例創建一個新的迭代器 //ArrayAccess public offsetExists ( mixed $index ) : bool public offsetGet ( mixed $index ) : mixed public offsetSet ( mixed $index , mixed $newval ) : void public offsetUnset ( mixed $index ) : void //Serializable public serialize ( void ) : string public unserialize ( string $serialized ) : void //Countable public count ( void ) : int //非繼承重寫方法 public __construct ([ mixed $input = array() [, int $flags = 0 [, string $iterator_class = "ArrayIterator" ]]] )//構造一個新的數組對象 public append ( mixed $value ) : void //追加新的值作為最后一個元素。 public asort ( void ) : void //按值對條目進行排序 public exchangeArray ( mixed $input ) : array //將數組換成另一個數組 public getArrayCopy ( void ) : array //創建ArrayObject的副本 public getFlags ( void ) : int //獲取行為標志 public getIteratorClass ( void ) : string //獲取ArrayObject的迭代器類名 public ksort ( void ) : void //按鍵對條目進行排序 public natcasesort ( void ) : void //使用不區分大小寫的“自然順序”算法對數組進行排序 public natsort ( void ) : void //使用“自然順序”算法對條目進行排序 public setFlags ( int $flags ) : void //設置行為標志 public setIteratorClass ( string $iterator_class ) : void //設置ArrayObject的迭代器類名 public uasort ( callable $cmp_function ) : void //使用用戶定義的比較函數對條目進行排序并維護密鑰關聯 public uksort ( callable $cmp_function ) : void //使用用戶定義的比較函數按鍵對條目進行排序 } ``` ## **例子1:** ``` <?php //打印全部數組元素 $arr =array('1'=>'one', '2'=>'two', '3'=>'three'); $arrayobject = new ArrayObject($arr);//構造一個ArrayObject對象 for($iterator= $arrayobject->getIterator();//構造一個迭代器 $iterator->valid();//檢查是否還含有元素 $iterator->next()){ //指向下個元素 echo $iterator->key() . ' => ' . $iterator->current() . "\n";//打印數組元素 } ?> ``` ## **例子2:** ``` <?php //重置數組指針 $arrayobject =new ArrayObject(); $arrayobject[] = 'zero'; $arrayobject[] = 'one'; $arrayobject[] = 'two'; $iterator= $arrayobject->getIterator(); $iterator->next(); echo $iterator->key(); // 1 $iterator->rewind(); //重置指針到頭部 echo $iterator->key(); // 0 ?> ``` 例子3 ``` $array = array('Buck','Jerry','Tomas'); $arrayObject = new ArrayObject($array); // Add new element $arrayObject->append('Tweety'); // We are getting the iterator of the object $iterator = $arrayObject->getIterator(); // Simple while loop while ($iterator->valid()) { echo $iterator->current() . "\n"; $iterator->next(); } /* Outputs */ Buck Jerry Tomas Tweety ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看