fork download
  1. <?php
  2.  
  3. $templateText = "Hi <John> , This is a test message from <9876543210>";
  4. $template_sample = preg_replace_callback("/<(?:(\d+)|[^>]+)>/", function($m) {
  5. return !empty($m[1]) ? '999999999' : 'test';
  6. }, $templateText);
  7. echo $template_sample;
Success #stdin #stdout 0.01s 82944KB
stdin
Standard input is empty
stdout
Hi test , This is a test message from 999999999