<?php

  $msg="Dear [[5]] We wish to continue the lesson with the [[6]]";

  preg_match_all("/\[\[(\d+)\]\]/", $msg, $matches);
  print_r($matches[1]);
?>