title: Forget index using it key value in laravel session
body: <p><strong>Result of $ compare:-</strong></p>
  <p><a href="https://i.stack.imgur.com/EFYkv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EFYkv.png" alt="enter image description here" /></a></p>
  <p><strong>code:-</strong></p>
  <pre><code>public function remove(Request $request)
  {
      $compare = $request-&gt;session()-&gt;get('compare', collect([]));
      $compare-&gt;forget($request-&gt;id);
      
      
      
      return back();
      
  }
  </code></pre>
  <p><strong>I want to delete data inside array $compare that i am retrieving data from session but delete relevant index including its value, using the key value.</strong></p>
  <pre><code>array:3 [
       0 =&gt; &quot;4&quot;
       1 =&gt; &quot;2&quot;
       2 =&gt; &quot;1&quot;   ]
  </code></pre>
  <p><code>forget()</code> or <code>pull()</code>
  <code>0 =&gt; &quot;4&quot;</code>
  using it's value <code>&quot;4&quot;</code></p>