title: how to get intervals from a range
body: <p>With algorithm how can I remove intervals within a range in php:</p>
  <p>Example 1:</p>
  <p>range: [8-22]</p>
  <p>input:</p>
  <blockquote>
  <p>interval: [11,13]
  interval: [16,18]</p>
  </blockquote>
  <p>output:</p>
  <blockquote>
  <p>[8,10] , [14,15], [19,22]</p>
  </blockquote>
  <p>Example 2:</p>
  <p>range: [8-22]</p>
  <p>input:</p>
  <blockquote>
  <p>interval: [8,11]
  interval: [16,18]</p>
  </blockquote>
  <p>output:</p>
  <blockquote>
  <p>[12,15], [19,22]</p>
  </blockquote>
  <p>thanks</p>