title: Remove all mentions of string from JSON in PHP
body: <p>In my web application, a user has the choice to enable and disable certain &quot;notification preferences&quot;, their choices are added to an array for each possible category and alerts within a JSON object, this is then saved to the database, I'm trying to remove ALL mentions of a specific &quot;channel&quot; if it's set without having to know what to loop over and what nested items I have.</p>
  <p>For instance, the following structure:</p>
  <pre class="lang-php prettyprint-override"><code>$channels = json_encode([
      'domains' =&gt; [
        'expiry' =&gt; ['mail', 'database', 'slack']
      ],
      'ssl' =&gt; [
        'expiry' =&gt; ['mail', 'database', 'slack']
      ],
      'monitors' =&gt; [
        'up' =&gt; ['mail', 'database', 'slack'],
        'down' =&gt; ['mail', 'database', 'slack']
      ]
  ]);
                
  
  $preferences = json_decode($channels);
  </code></pre>
  <p>I'd like to somehow find all mentions of **slack&quot;&quot; and then simply remove that item from my arrays, it may not always be in the same position, depending on what a user enables/disables...</p>
  <p>I was thinking of using <code>unset</code> or something similar?</p>
  <p>How can I achieve this with my code?</p>