Simple linked list in PHP

This code demonstrate the implementation of linked list using PHP. 
<?  class ListItem{
 var $key;
 var $next;
 var $prev;
   function ListItem($key=NULL){
 class LinkedList{
 var $head;
   function LinkedList(){
 function ListInsert(&$x){  
  $x->next = &$this->head;
  function ListSearch($k){
  while(!is_null($x) && $x->key!=$k){
 return $x;
  function ListDelete(&$x){
  if (!is_null($x->prev)) $x->prev->next=&$x->next;
  else $this->head=&$x->next;
  if (!is_null($x->next)) $x->next->prev=&$x->prev;
   function Listshow(){
  while ($b){
   echo 'key:'.$x->key."n";
Notes: I have difficulties in writing codes in blogsopt. The solution is, write the post in google docs, and send this article to the blogspot. Helluva job Kerul...

Popular Posts