downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

SplDoublyLinkedList::pop> <SplDoublyLinkedList::offsetSet
[edit] Last updated: Fri, 25 May 2012

view this page in

SplDoublyLinkedList::offsetUnset

(PHP 5 >= 5.3.0)

SplDoublyLinkedList::offsetUnset指定した $index の値を削除する

説明

void SplDoublyLinkedList::offsetUnset ( mixed $index )

指定したインデックスの値を削除します。

パラメータ

index

削除したいインデックス。

返り値

値を返しません。

エラー / 例外

index が範囲外を指すときや index が整数として解釈できないときに OutOfRangeException をスローします。



add a note add a note User Contributed Notes SplDoublyLinkedList::offsetUnset
marco dot paulo dot lopes at gmail dot com 30-May-2011 11:40
When unsetting an offset, the element will be removed from the double linked list. So the following code:

<?php

$obj
= new SplDoublyLinkedList();

$obj->push(4);
$obj->push(5);
$obj->push(6);

$obj->offsetUnset(1);
echo
"Our Linked List:";
print_r($obj);

?>

Will output:

Our Linked List:SplDoublyLinkedList Object
(
    [flags:SplDoublyLinkedList:private] => 0
    [dllist:SplDoublyLinkedList:private] => Array
        (
            [0] => 4
            [1] => 5
            [2] => 6
        )

)
Our New Linked List:SplDoublyLinkedList Object
(
    [flags:SplDoublyLinkedList:private] => 0
    [dllist:SplDoublyLinkedList:private] => Array
        (
            [0] => 4
            [1] => 6
        )

Notice that the element with the index 2 has now the index 1. The original element with index 1 did not only had it's value unset but was also removed from the list.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites