title: insert value to specific index in link list php
body: <p>I want to insert value to specific index in link list($wordsposition) in php.
  it trows me the exeption OutOfRangeException so I check my index in my linked list and it looks fine.
  it's my first time using linked list in php so I'm probebly doing something wrong but I don't really know what it is.. I would appreciate your help!</p>
  
  <p>here is my code:</p>
  
  <pre><code> $wordsposition = new SplDoublyLinkedList(); 
          foreach ($searchwords as $key =&gt; $value) {
              $wordsposition -&gt; push(array($value=&gt;' '));
          }
          print_r($wordsposition);
          echo "&lt;br&gt;";
          foreach ($searchwords as $key =&gt; $value) {
              $sql = "SELECT * FROM words WHERE word='$value'";
              $res = $conn-&gt;query($sql);
  
              if ($res-&gt;num_rows &gt; 0) {//check if find matching 
                  while ($row = $res-&gt;fetch_assoc()) {
                     $wordsposition-&gt;add($value,$row['num']);
                       echo " my index is: ".$value."&lt;br&gt;";
                       echo " my file is: ".$row['num']."&lt;br&gt;";
                  }
              }
          }
  </code></pre>
  
  <p>and here is my echos:</p>
  
  <pre><code>SplDoublyLinkedList Object ( [flags:SplDoublyLinkedList:private] =&gt; 0 [dllist:SplDoublyLinkedList:private] =&gt; Array ( [0] =&gt; Array ( [alright] =&gt; ) [1] =&gt; Array ( [always] =&gt; ) [2] =&gt; Array ( [around] =&gt; ) [3] =&gt; Array ( [and] =&gt; ) ) ) my index is: alright
  my file is: 0
  my index is: always
  my file is: 2
  my index is: always
  my file is: 3
  my index is: always
  my file is: 4
  my index is: around
  my file is: 0
  my index is: around
  my file is: 4
  my index is: and
  my file is: 0
  my index is: and
  my file is: 1
  my index is: and
  my file is: 2
  my index is: and
  my file is: 3
  my index is: and
  my file is: 4
  </code></pre>