title: binary search tree in php
body: <p>I've been having some problems implementing the function __toString() to print the binary tree, I've searched on the Internet but I couldnt find anything. I would be grateful if anyone could help me!</p>
  
  <p>Here's the code: </p>
  
  <pre><code>class Noeud {
      public $element;
      public $fd;
      public $fg;
  
      public function __construct($element){
          $this -&gt; element = $element;
          $this-&gt; fd = NULL;
          $this-&gt; fg = NULL;
      }   
  }
  
  
  class Arbre {
      private $racine;
  
      public function __construct(){
          $this-&gt;racine = NULL;
      }
      public function isEmpty() {
          return $this-&gt;racine === null;
      }
  
      //public function remove($element); 
  
      public function add($element){
          $noeud = new Noeud($element);
  
          if($this-&gt;isEmpty()){
              $this-&gt;racine = $noeud;
          }
          else{
              $this-&gt;addNode($noeud,$this-&gt;racine);
          }
      }
  
      public function addNode($noeud, &amp;$new){
          if($new === null){
              $new = $noeud;
          }
          else{
              if($node-&gt;element &gt; $new-&gt;element){
                  $this-&gt;addNode($node,$new-&gt;fd);
              }
              else if($node-&gt;element &lt; $new-&gt;element){
                  $this-&gt;addNode($node,$new-&gt;fg);
              }
              else{
                  return;
              }
          }
      } 
  
      public function __toString(){
            //
      }
  </code></pre>