fork(2) download
  1. <?php
  2.  
  3. $re = '/\[\[(.*?)]]/';
  4. $str = 'foo [[http://www.google.com|This Link points to google]] foo [[http://w...content-available-to-author-only...e.com|This Link points to more]]';
  5. echo preg_replace_callback($re, function($m) {
  6. $arr = explode("|", $m[1], 2);
  7. return '<a href="' . $arr[0] . '">'. $arr[1] . '</a>';
  8. }, $str);
Success #stdin #stdout 0.01s 82944KB
stdin
Standard input is empty
stdout
foo <a href="http://www.google.com">This Link points to google</a> foo <a href="http://w...content-available-to-author-only...e.com">This Link points to more</a>