title: How to find the changes between two lists, with immovable items (PHP)
body: <p>I'm trying to get the changes between two lists of articles in order to animate the transition between the two lists. Articles can be added, removed or moved (not swapped). </p>
  
  <p>However some articles can't be moved, and in each transition all other articles should be moved below those articles.</p>
  
  <p>For example, if each number represents an article id, and bold represents immovable articles, then:
  [1, <strong>2</strong>, 3, <strong>4</strong>, 5, 6] might become: [<strong>2</strong>, <strong>4</strong>, 1, 6, 7]</p>
  
  <p>I need to work out the changes required, for example in this case:</p>
  
  <ul>
  <li>Move 1 after 4</li>
  <li>Remove 5</li>
  <li>Add 7 after 6</li>
  </ul>
  
  <p>I have been using a diff algorithm, however it doesn't understand immovable items, so it might suggest:</p>
  
  <ul>
  <li>Move 2 to the beginning</li>
  <li>Move 4 after 2</li>
  <li>Remove 5</li>
  <li>Add 7 after 6</li>
  </ul>
  
  <p>I've tried various things, but can't get it to work reliably.</p>