Are there potential use cases for doubly linked lists in PHP applications?

Doubly linked lists can be useful in PHP applications when you need to efficiently insert or delete elements at both ends of a list. This data structure allows for bidirectional traversal, making it suitable for scenarios where you need to traverse a list in both forward and backward directions.

class Node {
    public $data;
    public $prev;
    public $next;

    public function __construct($data) {
        $this->data = $data;
        $this->prev = null;
        $this->next = null;
    }
}

class DoublyLinkedList {
    public $head;
    public $tail;

    public function __construct() {
        $this->head = null;
        $this->tail = null;
    }

    public function insertAtEnd($data) {
        $newNode = new Node($data);
        
        if ($this->head === null) {
            $this->head = $newNode;
            $this->tail = $newNode;
        } else {
            $newNode->prev = $this->tail;
            $this->tail->next = $newNode;
            $this->tail = $newNode;
        }
    }

    public function deleteFromFront() {
        if ($this->head === null) {
            return;
        }

        $this->head = $this->head->next;
        $this->head->prev = null;
    }
}

// Example usage
$dll = new DoublyLinkedList();
$dll->insertAtEnd(1);
$dll->insertAtEnd(2);
$dll->insertAtEnd(3);

$dll->deleteFromFront();