<?php $rulz="test closingdear [[12]]"; preg_match_all("/\[\[(\d+)\]\]/", $rulz, $matches); var_dump($matches[1]);?>
Standard input is empty
array(1) { [0]=> string(2) "12" }
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!