May 2017
Intermediate to advanced
340 pages
8h 16m
English
Searching for a node is pretty simple. We need to iterate through each node and check whether the target data matches with the node data. If the data is found, the node will be returned; otherwise, it will return FALSE. The implementation looks like this:
public function search(string $data = NULL) { if ($this->_totalNode) { $currentNode = $this->_firstNode; while ($currentNode !== NULL) { if ($currentNode->data === $data) { return $currentNode; } $currentNode = $currentNode->next; } } return FALSE; }
Read now
Unlock full access